@raac/rpc 2.0.0-beta.7 → 2.0.0-beta.8

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.
Files changed (31) hide show
  1. package/dist/RPCLibrary.js +14 -2
  2. package/dist/artifacts/core/collectors/fee-streamer/RentStreamer.sol/RentStreamer.json +838 -0
  3. package/dist/artifacts/mocks/core/tokens/USDCTokenLimited.sol/USDCTokenLimited.json +558 -0
  4. package/dist/configs/chains/11155111.json +28 -3
  5. package/dist/contracts/rentStreamer/_helpers.js +19 -0
  6. package/dist/contracts/rentStreamer/getScheduled.js +19 -0
  7. package/dist/contracts/rentStreamer/getState.js +40 -0
  8. package/dist/contracts/rentStreamer/previewRelease.js +23 -0
  9. package/dist/contracts/rentStreamer/release.js +22 -0
  10. package/dist/contracts/rentStreamer/sync.js +21 -0
  11. package/dist/types/RPCLibrary.d.ts +12 -0
  12. package/dist/types/contracts/rentStreamer/_helpers.d.ts +4 -0
  13. package/dist/types/contracts/rentStreamer/getScheduled.d.ts +12 -0
  14. package/dist/types/contracts/rentStreamer/getState.d.ts +33 -0
  15. package/dist/types/contracts/rentStreamer/previewRelease.d.ts +20 -0
  16. package/dist/types/contracts/rentStreamer/release.d.ts +12 -0
  17. package/dist/types/contracts/rentStreamer/sync.d.ts +11 -0
  18. package/dist/types/typechain-types/contracts/core/collectors/fee-streamer/RentStreamer.d.ts +422 -0
  19. package/dist/types/typechain-types/contracts/core/collectors/fee-streamer/index.d.ts +1 -0
  20. package/dist/types/typechain-types/contracts/core/collectors/index.d.ts +2 -0
  21. package/dist/types/typechain-types/contracts/mocks/core/tokens/USDCTokenLimited.d.ts +238 -0
  22. package/dist/types/typechain-types/contracts/mocks/core/tokens/index.d.ts +1 -0
  23. package/dist/types/typechain-types/factories/contracts/core/collectors/fee-streamer/RentStreamer__factory.d.ts +665 -0
  24. package/dist/types/typechain-types/factories/contracts/core/collectors/fee-streamer/index.d.ts +1 -0
  25. package/dist/types/typechain-types/factories/contracts/core/collectors/index.d.ts +1 -0
  26. package/dist/types/typechain-types/factories/contracts/mocks/core/tokens/USDCTokenLimited__factory.d.ts +439 -0
  27. package/dist/types/typechain-types/factories/contracts/mocks/core/tokens/index.d.ts +1 -0
  28. package/dist/types/typechain-types/index.d.ts +4 -0
  29. package/dist/types/utils/artifacts.d.ts +198 -0
  30. package/dist/utils/artifacts.js +4 -0
  31. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getState = void 0;
4
+ const amount_1 = require("../../utils/amount");
5
+ const _helpers_1 = require("./_helpers");
6
+ /**
7
+ * Reads the RentStreamer's configuration and running totals.
8
+ *
9
+ * @param chainId - The chain/network to use.
10
+ * @param provider - Optional ethers.js Provider instance.
11
+ * @returns The streamer state; see `RentStreamerState` for the unit of each field.
12
+ */
13
+ const getState = async (chainId, provider) => {
14
+ const contract = await (0, _helpers_1.getRentStreamerContract)(chainId, provider);
15
+ const [token, distributor, numEpochs, minBountyFee, maxBountyFee, bountyDuration, killed, processed, released, lastEpochProcessed] = await Promise.all([
16
+ contract.TOKEN(),
17
+ contract.GAUGE_REWARD_DISTRIBUTOR(),
18
+ contract.numEpochs(),
19
+ contract.minBountyFee(),
20
+ contract.maxBountyFee(),
21
+ contract.bountyDuration(),
22
+ contract.killed(),
23
+ contract.processed(),
24
+ contract.released(),
25
+ contract.lastEpochProcessed(),
26
+ ]);
27
+ return {
28
+ token,
29
+ distributor,
30
+ numEpochs: Number(numEpochs),
31
+ minBountyFee: (0, amount_1.toScaled)(minBountyFee, amount_1.WAD_DECIMALS),
32
+ maxBountyFee: (0, amount_1.toScaled)(maxBountyFee, amount_1.WAD_DECIMALS),
33
+ bountyDuration: Number(bountyDuration),
34
+ killed,
35
+ processed: (0, amount_1.toTokenAmount)(chainId, token, processed),
36
+ released: (0, amount_1.toTokenAmount)(chainId, token, released),
37
+ lastEpochProcessed: Number(lastEpochProcessed),
38
+ };
39
+ };
40
+ exports.getState = getState;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.previewRelease = void 0;
4
+ const amount_1 = require("../../utils/amount");
5
+ const _helpers_1 = require("./_helpers");
6
+ /**
7
+ * Previews what a `release` would move right now. All zero when the current epoch was already released or the
8
+ * streamer is killed. The bounty grows with time since the epoch start, so the real release can differ.
9
+ *
10
+ * @param chainId - The chain/network to use.
11
+ * @param provider - Optional ethers.js Provider instance.
12
+ * @returns The release preview, in the streamed token's base units.
13
+ */
14
+ const previewRelease = async (chainId, provider) => {
15
+ const contract = await (0, _helpers_1.getRentStreamerContract)(chainId, provider);
16
+ const [token, [amountToRelease, amountToDistribute, bountyFee]] = await Promise.all([contract.TOKEN(), contract.previewRelease()]);
17
+ return {
18
+ amountToRelease: (0, amount_1.toTokenAmount)(chainId, token, amountToRelease),
19
+ amountToDistribute: (0, amount_1.toTokenAmount)(chainId, token, amountToDistribute),
20
+ bountyFee: (0, amount_1.toTokenAmount)(chainId, token, bountyFee),
21
+ };
22
+ };
23
+ exports.previewRelease = previewRelease;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = void 0;
4
+ const _helpers_1 = require("./_helpers");
5
+ /**
6
+ * Releases the current epoch's buckets: pays the keeper bounty and deposits the rest into the RWA
7
+ * GaugeRewardsDistributor. Permissionless, once per epoch; reverts while the RWA gauge system has no active gauge.
8
+ *
9
+ * @param chainId - The chain/network to use.
10
+ * @param receiver - Address paid the bounty; the signer when omitted.
11
+ * @param signer - An ethers.js Signer instance (required).
12
+ * @returns The transaction.
13
+ */
14
+ const release = async (chainId, receiver, signer) => {
15
+ if (!signer)
16
+ throw new Error("Signer is required");
17
+ const contract = await (0, _helpers_1.getRentStreamerContract)(chainId, signer);
18
+ const tx = receiver ? await contract["release(address)"](receiver) : await contract["release()"]();
19
+ await tx.wait();
20
+ return tx;
21
+ };
22
+ exports.release = release;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sync = void 0;
4
+ const _helpers_1 = require("./_helpers");
5
+ /**
6
+ * Splits token sent to the streamer since the last sync over the next `numEpochs` weekly buckets. Permissionless;
7
+ * `release` also syncs first.
8
+ *
9
+ * @param chainId - The chain/network to use.
10
+ * @param signer - An ethers.js Signer instance (required).
11
+ * @returns The transaction.
12
+ */
13
+ const sync = async (chainId, signer) => {
14
+ if (!signer)
15
+ throw new Error("Signer is required");
16
+ const contract = await (0, _helpers_1.getRentStreamerContract)(chainId, signer);
17
+ const tx = await contract.sync();
18
+ await tx.wait();
19
+ return tx;
20
+ };
21
+ exports.sync = sync;
@@ -88,6 +88,11 @@ import { quoteBuy } from "./contracts/zeno/quoteBuy";
88
88
  import { ChainId } from "./configs/chains";
89
89
  import getBaseUri from "./nfts/getBaseUri";
90
90
  import claimRewardFromPool from "./contracts/feeCollector/claimRewardFromPool";
91
+ import { getState as getStateRentStreamer } from "./contracts/rentStreamer/getState";
92
+ import { previewRelease as previewReleaseRentStreamer } from "./contracts/rentStreamer/previewRelease";
93
+ import { getScheduled as getScheduledRentStreamer } from "./contracts/rentStreamer/getScheduled";
94
+ import { sync as syncRentStreamer } from "./contracts/rentStreamer/sync";
95
+ import { release as releaseRentStreamer } from "./contracts/rentStreamer/release";
91
96
  import getRawUserDepositsInLendingPool from "./pools/lendingPool/getRawUserDepositsInLendingPool";
92
97
  import getRawUserDepositInStabilityPool from "./pools/stabilityPool/getRawUserDepositsInStabilityPool";
93
98
  import getEligibleUserDeposits from "./pools/lendingPool/getEligibleUserDeposits";
@@ -399,6 +404,13 @@ declare class RPCLibrary {
399
404
  feeCollector: {
400
405
  claimRewardFromPool: typeof claimRewardFromPool;
401
406
  };
407
+ rentStreamer: {
408
+ getState: typeof getStateRentStreamer;
409
+ previewRelease: typeof previewReleaseRentStreamer;
410
+ getScheduled: typeof getScheduledRentStreamer;
411
+ sync: typeof syncRentStreamer;
412
+ release: typeof releaseRentStreamer;
413
+ };
402
414
  getABI: typeof getABI;
403
415
  pmTreasury: {
404
416
  getCollateralRatio: typeof getCollateralRatio;
@@ -0,0 +1,4 @@
1
+ import { Provider, Signer } from "ethers";
2
+ import { ChainId } from "../../configs/chains";
3
+ import { RentStreamer } from "../../typechain-types";
4
+ export declare function getRentStreamerContract(chainId: ChainId, runner?: Provider | Signer): Promise<RentStreamer>;
@@ -0,0 +1,12 @@
1
+ import { Provider } from "ethers";
2
+ import { ChainId } from "../../configs/chains";
3
+ import { TokenAmount } from "../../utils/amount";
4
+ /**
5
+ * Reads the amount bucketed for one epoch. Released epochs read zero.
6
+ *
7
+ * @param chainId - The chain/network to use.
8
+ * @param epoch - Epoch start timestamp, a multiple of one week.
9
+ * @param provider - Optional ethers.js Provider instance.
10
+ * @returns The scheduled amount in the streamed token's base units.
11
+ */
12
+ export declare const getScheduled: (chainId: ChainId, epoch: bigint, provider?: Provider) => Promise<TokenAmount>;
@@ -0,0 +1,33 @@
1
+ import { Provider } from "ethers";
2
+ import { ChainId } from "../../configs/chains";
3
+ import { ScaledValue, TokenAmount } from "../../utils/amount";
4
+ export interface RentStreamerState {
5
+ /** Streamed token (USDC). */
6
+ token: string;
7
+ /** GaugeRewardsDistributor every release deposits into. */
8
+ distributor: string;
9
+ /** Number of weekly buckets each synced amount is split over. */
10
+ numEpochs: number;
11
+ /** Keeper bounty at the start of an epoch, 18-decimal fraction of the released amount (1.0 = 100%). */
12
+ minBountyFee: ScaledValue;
13
+ /** Keeper bounty once `bountyDuration` has passed, 18-decimal fraction of the released amount (1.0 = 100%). */
14
+ maxBountyFee: ScaledValue;
15
+ /** Seconds over which the bounty ramps from min to max after an epoch starts. */
16
+ bountyDuration: number;
17
+ /** Whether the streamer was permanently shut down. */
18
+ killed: boolean;
19
+ /** Token synced into buckets and not yet released. */
20
+ processed: TokenAmount;
21
+ /** Token released so far, bounties included. */
22
+ released: TokenAmount;
23
+ /** Start timestamp of the last released epoch. */
24
+ lastEpochProcessed: number;
25
+ }
26
+ /**
27
+ * Reads the RentStreamer's configuration and running totals.
28
+ *
29
+ * @param chainId - The chain/network to use.
30
+ * @param provider - Optional ethers.js Provider instance.
31
+ * @returns The streamer state; see `RentStreamerState` for the unit of each field.
32
+ */
33
+ export declare const getState: (chainId: ChainId, provider?: Provider) => Promise<RentStreamerState>;
@@ -0,0 +1,20 @@
1
+ import { Provider } from "ethers";
2
+ import { ChainId } from "../../configs/chains";
3
+ import { TokenAmount } from "../../utils/amount";
4
+ export interface RentStreamerReleasePreview {
5
+ /** Total the next release takes out of the buckets, bounty included. */
6
+ amountToRelease: TokenAmount;
7
+ /** Part deposited into the RWA GaugeRewardsDistributor. */
8
+ amountToDistribute: TokenAmount;
9
+ /** Part paid to the keeper that calls `release`. */
10
+ bountyFee: TokenAmount;
11
+ }
12
+ /**
13
+ * Previews what a `release` would move right now. All zero when the current epoch was already released or the
14
+ * streamer is killed. The bounty grows with time since the epoch start, so the real release can differ.
15
+ *
16
+ * @param chainId - The chain/network to use.
17
+ * @param provider - Optional ethers.js Provider instance.
18
+ * @returns The release preview, in the streamed token's base units.
19
+ */
20
+ export declare const previewRelease: (chainId: ChainId, provider?: Provider) => Promise<RentStreamerReleasePreview>;
@@ -0,0 +1,12 @@
1
+ import { Signer } from "ethers";
2
+ import { ChainId } from "../../configs/chains";
3
+ /**
4
+ * Releases the current epoch's buckets: pays the keeper bounty and deposits the rest into the RWA
5
+ * GaugeRewardsDistributor. Permissionless, once per epoch; reverts while the RWA gauge system has no active gauge.
6
+ *
7
+ * @param chainId - The chain/network to use.
8
+ * @param receiver - Address paid the bounty; the signer when omitted.
9
+ * @param signer - An ethers.js Signer instance (required).
10
+ * @returns The transaction.
11
+ */
12
+ export declare const release: (chainId: ChainId, receiver: string | undefined, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
@@ -0,0 +1,11 @@
1
+ import { Signer } from "ethers";
2
+ import { ChainId } from "../../configs/chains";
3
+ /**
4
+ * Splits token sent to the streamer since the last sync over the next `numEpochs` weekly buckets. Permissionless;
5
+ * `release` also syncs first.
6
+ *
7
+ * @param chainId - The chain/network to use.
8
+ * @param signer - An ethers.js Signer instance (required).
9
+ * @returns The transaction.
10
+ */
11
+ export declare const sync: (chainId: ChainId, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;