@raac/rpc 2.0.0-beta.23 → 2.0.0-beta.25

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.
@@ -193,6 +193,7 @@ const requestWithdraw_1 = require("./pools/stabilityPool/requestWithdraw");
193
193
  // PSM
194
194
  const getVaultInfo_1 = require("./contracts/psm/getVaultInfo");
195
195
  const getVaultSettings_1 = require("./contracts/psm/getVaultSettings");
196
+ const listVaults_1 = require("./contracts/psm/listVaults");
196
197
  const getState_3 = __importDefault(require("./contracts/housePrices/getState"));
197
198
  const getState_4 = __importDefault(require("./contracts/crvUSDToUSDOracle/getState"));
198
199
  const getRoles_1 = __importDefault(require("./contracts/getRoles"));
@@ -800,6 +801,7 @@ class RPCLibrary {
800
801
  },
801
802
  };
802
803
  this.psm = {
804
+ listVaults: listVaults_1.listVaults,
803
805
  getVaultInfo: getVaultInfo_1.getVaultInfo,
804
806
  getVaultSettings: getVaultSettings_1.getVaultSettings,
805
807
  previewDeposit: previewDeposit_2.previewDeposit,
@@ -136,7 +136,10 @@
136
136
  "version": "1.0.0",
137
137
  "name": "RAAC Peg Stability Module sUSDS",
138
138
  "contract": "0xB2102B4d8802648EC6A9e89ACD46b4B799833469",
139
- "rateProvider": "0x9a6b5BDA2128e6341175c79E43Cd2A7E0C5F5b21"
139
+ "rateProvider": "0x9a6b5BDA2128e6341175c79E43Cd2A7E0C5F5b21",
140
+ "pairingToken": "susds",
141
+ "baseAsset": "pmusd",
142
+ "shareToken": "rpsm-susds"
140
143
  }
141
144
  },
142
145
  "pools": {
@@ -182,6 +185,13 @@
182
185
  "decimals": 18,
183
186
  "contract": "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD"
184
187
  },
188
+ "rpsm-susds": {
189
+ "id": "rpsm-susds",
190
+ "name": "RAAC PSM sUSDS Share",
191
+ "symbol": "rpsm-sUSDS",
192
+ "decimals": 18,
193
+ "contract": "0xB2102B4d8802648EC6A9e89ACD46b4B799833469"
194
+ },
185
195
  "xpm": {
186
196
  "id": "xpm",
187
197
  "name": "xPM",
@@ -191,7 +191,10 @@
191
191
  "version": "1.0.0",
192
192
  "name": "RAAC Peg Stability Module sUSDS",
193
193
  "contract": "0x1c7Dfbc9bea1d8b6eb33ce8C715dC5313DC3d8B8",
194
- "rateProvider": "0xC0508Cf612C507E22E75C89501E7A1F64D634bd9"
194
+ "rateProvider": "0xC0508Cf612C507E22E75C89501E7A1F64D634bd9",
195
+ "pairingToken": "susds",
196
+ "baseAsset": "pmusd",
197
+ "shareToken": "rpsm-susds"
195
198
  }
196
199
  },
197
200
  "pools": {
@@ -246,6 +249,13 @@
246
249
  "flavour": "stableswap",
247
250
  "coins": ["pmusd", "usdc"]
248
251
  },
252
+ "pmusd-susds": {
253
+ "id": "pmusd-susds",
254
+ "name": "pmUSD / sUSDS",
255
+ "contract": "0xdDCD3229FD143aFCdE31bA2FfA3B23C62d5F688b",
256
+ "flavour": "stableswap",
257
+ "coins": ["pmusd", "susds"]
258
+ },
249
259
  "leraac-raac-pmusd": {
250
260
  "id": "leraac-raac-pmusd",
251
261
  "name": "leRAAC / RAAC / pmUSD",
@@ -332,6 +342,13 @@
332
342
  "decimals": 18,
333
343
  "contract": "0xAADD480013475e416cAC2F511697060c920bEE67"
334
344
  },
345
+ "rpsm-susds": {
346
+ "id": "rpsm-susds",
347
+ "name": "RAAC PSM sUSDS Share",
348
+ "symbol": "rpsm-sUSDS",
349
+ "decimals": 18,
350
+ "contract": "0x1c7Dfbc9bea1d8b6eb33ce8C715dC5313DC3d8B8"
351
+ },
335
352
  "rtoken": {
336
353
  "id": "rtoken",
337
354
  "name": "RToken",
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.resolvePsmVault = resolvePsmVault;
7
+ exports.getPsmVaults = getPsmVaults;
8
+ exports.resolvePsmAsset = resolvePsmAsset;
7
9
  exports.getPsmVaultMajor = getPsmVaultMajor;
8
10
  exports.getPsmVaultContract = getPsmVaultContract;
9
11
  exports.getPairingToken = getPairingToken;
@@ -32,6 +34,21 @@ function resolvePsmVault(chainId, vaultKeyOrAddress) {
32
34
  throw new Error(`PSM vault "${vaultKeyOrAddress}" not configured for chain ${chainId}`);
33
35
  return { key, entry: psm[key] };
34
36
  }
37
+ /** The PSM vaults configured on `chainId`, keyed by config key; empty when the chain has none. */
38
+ function getPsmVaults(chainId) {
39
+ return chains_1.default[chainId]?.psm ?? {};
40
+ }
41
+ /**
42
+ * The `assets` entry a PSM vault refers to by key (its pairing token, base asset or share token).
43
+ * @throws When the chain has no such asset, so a misconfigured vault fails loudly instead of formatting with 18 decimals.
44
+ */
45
+ function resolvePsmAsset(chainId, assetKey) {
46
+ const assets = chains_1.default[chainId]?.assets;
47
+ const asset = assets?.[assetKey];
48
+ if (!asset)
49
+ throw new Error(`PSM asset "${assetKey}" not configured for chain ${chainId}`);
50
+ return asset;
51
+ }
35
52
  /** The first PSMVault major that calls the pairing token `pairingToken` instead of `savingsToken`. */
36
53
  const PAIRING_TOKEN_RENAME_MAJOR = 3;
37
54
  /**
@@ -17,6 +17,7 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
17
17
  provider = (0, _helpers_1.getDefaultProvider)(chainId);
18
18
  const { entry } = (0, _helpers_1.resolvePsmVault)(chainId, vaultKeyOrAddress);
19
19
  const contractAddress = entry.contract;
20
+ const { pairingToken: pairingKey, baseAsset: baseKey } = entry;
20
21
  try {
21
22
  const vault = (0, _helpers_1.getPsmVaultContract)(chainId, vaultKeyOrAddress, provider);
22
23
  const major = (0, _helpers_1.getPsmVaultMajor)(entry);
@@ -76,32 +77,32 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
76
77
  shares: (0, amount_1.toAmount)(redeemRequest[0], Number(vaultDecimals), entry.id),
77
78
  exitTime: Number(redeemRequest[1]),
78
79
  },
79
- savingsTokenAllowance: (0, amount_1.toTokenAmount)(chainId, "susds", savingsTokenAllowance),
80
- baseAssetAllowance: (0, amount_1.toTokenAmount)(chainId, "pmusd", baseAssetAllowance),
80
+ savingsTokenAllowance: (0, amount_1.toTokenAmount)(chainId, pairingKey, savingsTokenAllowance),
81
+ baseAssetAllowance: (0, amount_1.toTokenAmount)(chainId, baseKey, baseAssetAllowance),
81
82
  };
82
83
  }
83
84
  return {
84
85
  version: entry.version,
85
- totalAssets: (0, amount_1.toTokenAmount)(chainId, "pmusd", totalAssets),
86
+ totalAssets: (0, amount_1.toTokenAmount)(chainId, baseKey, totalAssets),
86
87
  totalSupply: (0, amount_1.toAmount)(totalSupply, Number(vaultDecimals), entry.id),
87
- depositCap: (0, amount_1.toTokenAmount)(chainId, "susds", depositCap),
88
+ depositCap: (0, amount_1.toTokenAmount)(chainId, pairingKey, depositCap),
88
89
  swapFee,
89
90
  computeWithdrawFee,
90
91
  withdrawTime: Number(withdrawTime),
91
92
  withdrawTimeLimit: Number(withdrawTimeLimit),
92
- dripRate: (0, amount_1.toTokenAmount)(chainId, "pmusd", dripRate),
93
+ dripRate: (0, amount_1.toTokenAmount)(chainId, baseKey, dripRate),
93
94
  dripEnd: Number(dripEnd),
94
- pendingRewards: (0, amount_1.toTokenAmount)(chainId, "pmusd", pendingRewards),
95
+ pendingRewards: (0, amount_1.toTokenAmount)(chainId, baseKey, pendingRewards),
95
96
  vaultComposition: {
96
- baseAssetValue: (0, amount_1.toTokenAmount)(chainId, "pmusd", vaultComposition[0]),
97
- savingsTokenValue: (0, amount_1.toTokenAmount)(chainId, "pmusd", vaultComposition[1]),
98
- total: (0, amount_1.toTokenAmount)(chainId, "pmusd", vaultComposition[2]),
97
+ baseAssetValue: (0, amount_1.toTokenAmount)(chainId, baseKey, vaultComposition[0]),
98
+ savingsTokenValue: (0, amount_1.toTokenAmount)(chainId, baseKey, vaultComposition[1]),
99
+ total: (0, amount_1.toTokenAmount)(chainId, baseKey, vaultComposition[2]),
99
100
  },
100
101
  minWithdrawFee,
101
102
  maxWithdrawFee,
102
103
  rebalancer,
103
104
  baseAssetModule: baseAssetModule && baseAssetModule !== ZERO_ADDRESS ? baseAssetModule : null,
104
- rebalanceThreshold: (0, amount_1.toTokenAmount)(chainId, "pmusd", rebalanceThreshold),
105
+ rebalanceThreshold: (0, amount_1.toTokenAmount)(chainId, baseKey, rebalanceThreshold),
105
106
  reserveRatioFloor: (0, amount_1.toScaled)(reserveRatioFloor),
106
107
  dripDuration: Number(dripDuration),
107
108
  paused,
@@ -110,7 +111,7 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
110
111
  savingsToken,
111
112
  baseAsset,
112
113
  savingsTokenRate: (0, amount_1.toScaled)(savingsTokenRate),
113
- vaultSavingsTokenBalance: (0, amount_1.toTokenAmount)(chainId, "susds", vaultSavingsTokenBalance),
114
+ vaultSavingsTokenBalance: (0, amount_1.toTokenAmount)(chainId, pairingKey, vaultSavingsTokenBalance),
114
115
  moduleVaultBalance,
115
116
  moduleConvertToAssets,
116
117
  user,
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listVaults = listVaults;
4
+ const _helpers_1 = require("./_helpers");
5
+ /**
6
+ * Lists the PSM vaults configured on a chain, in config order, with their pairing token, base asset and share token
7
+ * resolved from the chain's `assets`. Reads no chain state.
8
+ * @param chainId - The chain/network to use.
9
+ * @returns An empty list for a chain without PSM vaults.
10
+ * @throws When a vault refers to an asset key the chain does not configure.
11
+ */
12
+ function listVaults(chainId) {
13
+ return Object.entries((0, _helpers_1.getPsmVaults)(chainId)).map(([key, entry]) => {
14
+ const withKey = (assetKey) => ({ ...(0, _helpers_1.resolvePsmAsset)(chainId, assetKey), key: assetKey });
15
+ return {
16
+ key,
17
+ id: entry.id,
18
+ name: entry.name,
19
+ version: entry.version,
20
+ contract: entry.contract,
21
+ rateProvider: entry.rateProvider,
22
+ pairingToken: withKey(entry.pairingToken),
23
+ baseAsset: withKey(entry.baseAsset),
24
+ shareToken: withKey(entry.shareToken),
25
+ };
26
+ });
27
+ }
@@ -134,6 +134,7 @@ import { getWithdrawTimelockConfig as getStabilityPoolWithdrawTimelockConfig } f
134
134
  import { requestWithdraw as requestStabilityPoolWithdraw } from "./pools/stabilityPool/requestWithdraw";
135
135
  import { getVaultInfo as getPsmVaultInfo } from "./contracts/psm/getVaultInfo";
136
136
  import { getVaultSettings as getPsmVaultSettings } from "./contracts/psm/getVaultSettings";
137
+ import { listVaults as listPsmVaults } from "./contracts/psm/listVaults";
137
138
  import getHousePricesState from "./contracts/housePrices/getState";
138
139
  import getCrvUSDToUSDOracleState from "./contracts/crvUSDToUSDOracle/getState";
139
140
  import getRoles from "./contracts/getRoles";
@@ -682,6 +683,7 @@ declare class RPCLibrary {
682
683
  };
683
684
  };
684
685
  psm: {
686
+ listVaults: typeof listPsmVaults;
685
687
  getVaultInfo: typeof getPsmVaultInfo;
686
688
  getVaultSettings: typeof getPsmVaultSettings;
687
689
  previewDeposit: typeof previewDepositPsm;
@@ -135,6 +135,9 @@ declare const chains: {
135
135
  name: string;
136
136
  contract: string;
137
137
  rateProvider: string;
138
+ pairingToken: string;
139
+ baseAsset: string;
140
+ shareToken: string;
138
141
  };
139
142
  };
140
143
  pools: {
@@ -180,6 +183,13 @@ declare const chains: {
180
183
  decimals: number;
181
184
  contract: string;
182
185
  };
186
+ "rpsm-susds": {
187
+ id: string;
188
+ name: string;
189
+ symbol: string;
190
+ decimals: number;
191
+ contract: string;
192
+ };
183
193
  xpm: {
184
194
  id: string;
185
195
  name: string;
@@ -403,6 +413,9 @@ export declare const configs: {
403
413
  name: string;
404
414
  contract: string;
405
415
  rateProvider: string;
416
+ pairingToken: string;
417
+ baseAsset: string;
418
+ shareToken: string;
406
419
  };
407
420
  };
408
421
  pools: {
@@ -448,6 +461,13 @@ export declare const configs: {
448
461
  decimals: number;
449
462
  contract: string;
450
463
  };
464
+ "rpsm-susds": {
465
+ id: string;
466
+ name: string;
467
+ symbol: string;
468
+ decimals: number;
469
+ contract: string;
470
+ };
451
471
  xpm: {
452
472
  id: string;
453
473
  name: string;
@@ -135,6 +135,9 @@ declare function getChainsConfig(): {
135
135
  name: string;
136
136
  contract: string;
137
137
  rateProvider: string;
138
+ pairingToken: string;
139
+ baseAsset: string;
140
+ shareToken: string;
138
141
  };
139
142
  };
140
143
  pools: {
@@ -180,6 +183,13 @@ declare function getChainsConfig(): {
180
183
  decimals: number;
181
184
  contract: string;
182
185
  };
186
+ "rpsm-susds": {
187
+ id: string;
188
+ name: string;
189
+ symbol: string;
190
+ decimals: number;
191
+ contract: string;
192
+ };
183
193
  xpm: {
184
194
  id: string;
185
195
  name: string;
@@ -1,6 +1,6 @@
1
1
  import { ethers, Provider, Signer } from "ethers";
2
2
  import { ChainId } from "../../configs/chains";
3
- import { PsmVaultEntry } from "../../configs/chains/chain";
3
+ import { Asset, Psm, PsmVaultEntry } from "../../configs/chains/chain";
4
4
  import { PSMVault } from "../../typechain-types/psm/PSMVault";
5
5
  import { RateProvider } from "../../typechain-types/psm/RateProvider";
6
6
  /**
@@ -11,6 +11,13 @@ export declare function resolvePsmVault(chainId: ChainId, vaultKeyOrAddress: str
11
11
  key: string;
12
12
  entry: PsmVaultEntry;
13
13
  };
14
+ /** The PSM vaults configured on `chainId`, keyed by config key; empty when the chain has none. */
15
+ export declare function getPsmVaults(chainId: ChainId): Psm;
16
+ /**
17
+ * The `assets` entry a PSM vault refers to by key (its pairing token, base asset or share token).
18
+ * @throws When the chain has no such asset, so a misconfigured vault fails loudly instead of formatting with 18 decimals.
19
+ */
20
+ export declare function resolvePsmAsset(chainId: ChainId, assetKey: string): Asset;
14
21
  /**
15
22
  * Major version of the vault's implementation, from the config entry's `version`.
16
23
  * @throws When the version is missing, malformed, or has no ABI in this library.
@@ -0,0 +1,34 @@
1
+ import { ChainId } from "../../configs/chains";
2
+ import { Asset } from "../../configs/chains/chain";
3
+ /** A configured PSM vault with its tokens resolved from the chain's `assets`. */
4
+ export interface PsmVaultDescriptor {
5
+ /** Config key, e.g. "rpsm-susds"; accepted by every `psm.*` call in place of the address. */
6
+ key: string;
7
+ id: string;
8
+ name: string;
9
+ /** Implementation semver; its major decides which getters the `psm.*` reads call. */
10
+ version: string;
11
+ /** The vault contract, which is also its share token. */
12
+ contract: string;
13
+ rateProvider: string;
14
+ /** The token deposited into the vault and swapped against the base asset, with its `assets` key. */
15
+ pairingToken: Asset & {
16
+ key: string;
17
+ };
18
+ /** The vault's base asset (pmUSD), with its `assets` key. */
19
+ baseAsset: Asset & {
20
+ key: string;
21
+ };
22
+ /** The vault's share token, with its `assets` key. */
23
+ shareToken: Asset & {
24
+ key: string;
25
+ };
26
+ }
27
+ /**
28
+ * Lists the PSM vaults configured on a chain, in config order, with their pairing token, base asset and share token
29
+ * resolved from the chain's `assets`. Reads no chain state.
30
+ * @param chainId - The chain/network to use.
31
+ * @returns An empty list for a chain without PSM vaults.
32
+ * @throws When a vault refers to an asset key the chain does not configure.
33
+ */
34
+ export declare function listVaults(chainId: ChainId): PsmVaultDescriptor[];
@@ -137,6 +137,9 @@ export declare const getConfigs: () => {
137
137
  name: string;
138
138
  contract: string;
139
139
  rateProvider: string;
140
+ pairingToken: string;
141
+ baseAsset: string;
142
+ shareToken: string;
140
143
  };
141
144
  };
142
145
  pools: {
@@ -182,6 +185,13 @@ export declare const getConfigs: () => {
182
185
  decimals: number;
183
186
  contract: string;
184
187
  };
188
+ "rpsm-susds": {
189
+ id: string;
190
+ name: string;
191
+ symbol: string;
192
+ decimals: number;
193
+ contract: string;
194
+ };
185
195
  xpm: {
186
196
  id: string;
187
197
  name: string;
@@ -413,6 +423,9 @@ declare const _default: {
413
423
  name: string;
414
424
  contract: string;
415
425
  rateProvider: string;
426
+ pairingToken: string;
427
+ baseAsset: string;
428
+ shareToken: string;
416
429
  };
417
430
  };
418
431
  pools: {
@@ -458,6 +471,13 @@ declare const _default: {
458
471
  decimals: number;
459
472
  contract: string;
460
473
  };
474
+ "rpsm-susds": {
475
+ id: string;
476
+ name: string;
477
+ symbol: string;
478
+ decimals: number;
479
+ contract: string;
480
+ };
461
481
  xpm: {
462
482
  id: string;
463
483
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raac/rpc",
3
- "version": "2.0.0-beta.23",
3
+ "version": "2.0.0-beta.25",
4
4
  "description": "RPC Library for RAAC",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",