@raac/rpc 1.2.0-beta.1 → 1.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RPCLibrary.js +6 -0
- package/dist/contracts/tokens/veRAAC/getRagequitEpochs.js +30 -0
- package/dist/contracts/tokens/veRAAC/increaseWithApproval.js +37 -0
- package/dist/contracts/tokens/veRAAC/index.js +7 -1
- package/dist/contracts/tokens/veRAAC/lockWithApproval.js +40 -0
- package/dist/types/RPCLibrary.d.ts +6 -0
- package/dist/types/contracts/tokens/veRAAC/getRagequitEpochs.d.ts +11 -0
- package/dist/types/contracts/tokens/veRAAC/increaseWithApproval.d.ts +13 -0
- package/dist/types/contracts/tokens/veRAAC/index.d.ts +3 -0
- package/dist/types/contracts/tokens/veRAAC/lockWithApproval.d.ts +14 -0
- package/package.json +1 -1
package/dist/RPCLibrary.js
CHANGED
|
@@ -215,6 +215,9 @@ const distributeRewards_1 = require("./contracts/tokens/veRAAC/distributeRewards
|
|
|
215
215
|
const getUserPointHistory_1 = require("./contracts/tokens/veRAAC/getUserPointHistory");
|
|
216
216
|
const getCheckpoint_1 = require("./contracts/tokens/veRAAC/getCheckpoint");
|
|
217
217
|
const getRagequitRequest_1 = require("./contracts/tokens/veRAAC/getRagequitRequest");
|
|
218
|
+
const getRagequitEpochs_1 = require("./contracts/tokens/veRAAC/getRagequitEpochs");
|
|
219
|
+
const lockWithApproval_1 = require("./contracts/tokens/veRAAC/lockWithApproval");
|
|
220
|
+
const increaseWithApproval_1 = require("./contracts/tokens/veRAAC/increaseWithApproval");
|
|
218
221
|
const getRawBalanceOf_2 = require("./contracts/tokens/veRAAC/getRawBalanceOf");
|
|
219
222
|
const getRawTotalSupply_2 = require("./contracts/tokens/veRAAC/getRawTotalSupply");
|
|
220
223
|
const getEffectiveLockEnd_1 = require("./contracts/tokens/veRAAC/getEffectiveLockEnd");
|
|
@@ -386,6 +389,9 @@ class RPCLibrary {
|
|
|
386
389
|
getUserPointHistory: getUserPointHistory_1.getUserPointHistory,
|
|
387
390
|
getCheckpoint: getCheckpoint_1.getCheckpoint,
|
|
388
391
|
getRagequitRequest: getRagequitRequest_1.getRagequitRequest,
|
|
392
|
+
getRagequitEpochs: getRagequitEpochs_1.getRagequitEpochs,
|
|
393
|
+
lockWithApproval: lockWithApproval_1.lockWithApproval,
|
|
394
|
+
increaseWithApproval: increaseWithApproval_1.increaseWithApproval,
|
|
389
395
|
getRawBalanceOf: getRawBalanceOf_2.getRawBalanceOf,
|
|
390
396
|
getRawTotalSupply: getRawTotalSupply_2.getRawTotalSupply,
|
|
391
397
|
getEffectiveLockEnd: getEffectiveLockEnd_1.getEffectiveLockEnd,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getRagequitEpochs = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const chains_1 = __importDefault(require("../../../configs/chains"));
|
|
9
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
10
|
+
const artifacts_1 = require("../../../utils/artifacts");
|
|
11
|
+
/**
|
|
12
|
+
* Gets the ragequit cooldown duration (in epochs) from the veRAAC contract.
|
|
13
|
+
* The actual cooldown in seconds is `ragequitEpochs * epochDuration`.
|
|
14
|
+
*
|
|
15
|
+
* @param chainId - The chain/network to use.
|
|
16
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
17
|
+
* @returns Number of epochs the user must wait between ragequit initiation and finalization.
|
|
18
|
+
*/
|
|
19
|
+
const getRagequitEpochs = async (chainId, provider) => {
|
|
20
|
+
if (!provider) {
|
|
21
|
+
const rpc = chains_1.default[chainId].rpcs[0];
|
|
22
|
+
provider = new ethers_1.ethers.JsonRpcProvider(rpc);
|
|
23
|
+
}
|
|
24
|
+
const contractAddress = (0, getContractAddress_1.getContractAddress)(chainId, "veraac");
|
|
25
|
+
const abi = (0, artifacts_1.getABI)("veraac");
|
|
26
|
+
const contract = new ethers_1.ethers.Contract(contractAddress, abi, provider);
|
|
27
|
+
const epochs = await contract.ragequitEpochs();
|
|
28
|
+
return Number(epochs);
|
|
29
|
+
};
|
|
30
|
+
exports.getRagequitEpochs = getRagequitEpochs;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.increaseWithApproval = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
9
|
+
const getAllowance_1 = __importDefault(require("../../../wallet/assets/getAllowance"));
|
|
10
|
+
const approveAsset_1 = __importDefault(require("../../../wallet/assets/approveAsset"));
|
|
11
|
+
const increase_1 = require("./increase");
|
|
12
|
+
/**
|
|
13
|
+
* Increases the amount of tokens in an existing lock, auto-approving the veRAAC
|
|
14
|
+
* contract first if the current allowance is insufficient.
|
|
15
|
+
*
|
|
16
|
+
* @param chainId - The chain/network to use.
|
|
17
|
+
* @param amountToAdd - Additional RAAC amount to add to the existing lock (decimal string).
|
|
18
|
+
* @param epochEnd - The epoch end time of the existing lock to increase.
|
|
19
|
+
* @param signer - An ethers.js Signer (must be connected to wallet).
|
|
20
|
+
* @returns Transaction receipt of the increase tx.
|
|
21
|
+
*/
|
|
22
|
+
const increaseWithApproval = async (chainId, amountToAdd, epochEnd, signer) => {
|
|
23
|
+
if (!signer) {
|
|
24
|
+
throw new Error("Signer is required");
|
|
25
|
+
}
|
|
26
|
+
const userAddress = await signer.getAddress();
|
|
27
|
+
const veRaacAddress = (0, getContractAddress_1.getContractAddress)(chainId, "veraac");
|
|
28
|
+
const amountWei = ethers_1.ethers.parseEther(amountToAdd);
|
|
29
|
+
const allowance = await (0, getAllowance_1.default)(chainId, "raactoken", userAddress, veRaacAddress, signer.provider ?? undefined);
|
|
30
|
+
if (allowance < amountWei) {
|
|
31
|
+
console.log("[increaseWithApproval] Approving RAAC for veRAAC contract…");
|
|
32
|
+
await (0, approveAsset_1.default)(chainId, "raactoken", veRaacAddress, amountToAdd, signer);
|
|
33
|
+
console.log("[increaseWithApproval] Approval successful");
|
|
34
|
+
}
|
|
35
|
+
return (0, increase_1.increase)(chainId, amountWei, epochEnd, signer);
|
|
36
|
+
};
|
|
37
|
+
exports.increaseWithApproval = increaseWithApproval;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.distributeRewards = exports.finalizeRagequit = exports.ragequitLock = exports.ragequitAll = exports.claimReward = exports.withdraw = exports.extend = exports.increase = exports.lock = exports.getMaxUnclaimedDistributions = exports.getRagequitRequest = exports.getCheckpoint = exports.getUserPointHistory = exports.getEarned = exports.getClaimable = exports.getClaimed = exports.getRawTotalSupply = exports.getRawBalanceOf = exports.getTotalSupplyAtTime = exports.getTotalSupplyAt = exports.getBalanceAtTime = exports.getBalanceAt = exports.getEffectiveLockEnd = exports.getMinLockEnd = exports.getMaxLockEnd = exports.getGlobalLockInfo = exports.getLocks = exports.getLockedBalance = exports.getTotalSupply = exports.getBalance = void 0;
|
|
3
|
+
exports.distributeRewards = exports.finalizeRagequit = exports.ragequitLock = exports.ragequitAll = exports.claimReward = exports.withdraw = exports.extend = exports.increaseWithApproval = exports.increase = exports.lockWithApproval = exports.lock = exports.getMaxUnclaimedDistributions = exports.getRagequitEpochs = exports.getRagequitRequest = exports.getCheckpoint = exports.getUserPointHistory = exports.getEarned = exports.getClaimable = exports.getClaimed = exports.getRawTotalSupply = exports.getRawBalanceOf = exports.getTotalSupplyAtTime = exports.getTotalSupplyAt = exports.getBalanceAtTime = exports.getBalanceAt = exports.getEffectiveLockEnd = exports.getMinLockEnd = exports.getMaxLockEnd = exports.getGlobalLockInfo = exports.getLocks = exports.getLockedBalance = exports.getTotalSupply = exports.getBalance = void 0;
|
|
4
4
|
var getBalance_1 = require("./getBalance");
|
|
5
5
|
Object.defineProperty(exports, "getBalance", { enumerable: true, get: function () { return getBalance_1.getBalance; } });
|
|
6
6
|
var getTotalSupply_1 = require("./getTotalSupply");
|
|
@@ -41,12 +41,18 @@ var getCheckpoint_1 = require("./getCheckpoint");
|
|
|
41
41
|
Object.defineProperty(exports, "getCheckpoint", { enumerable: true, get: function () { return getCheckpoint_1.getCheckpoint; } });
|
|
42
42
|
var getRagequitRequest_1 = require("./getRagequitRequest");
|
|
43
43
|
Object.defineProperty(exports, "getRagequitRequest", { enumerable: true, get: function () { return getRagequitRequest_1.getRagequitRequest; } });
|
|
44
|
+
var getRagequitEpochs_1 = require("./getRagequitEpochs");
|
|
45
|
+
Object.defineProperty(exports, "getRagequitEpochs", { enumerable: true, get: function () { return getRagequitEpochs_1.getRagequitEpochs; } });
|
|
44
46
|
var getMaxUnclaimedDistributions_1 = require("./getMaxUnclaimedDistributions");
|
|
45
47
|
Object.defineProperty(exports, "getMaxUnclaimedDistributions", { enumerable: true, get: function () { return getMaxUnclaimedDistributions_1.getMaxUnclaimedDistributions; } });
|
|
46
48
|
var lock_1 = require("./lock");
|
|
47
49
|
Object.defineProperty(exports, "lock", { enumerable: true, get: function () { return lock_1.lock; } });
|
|
50
|
+
var lockWithApproval_1 = require("./lockWithApproval");
|
|
51
|
+
Object.defineProperty(exports, "lockWithApproval", { enumerable: true, get: function () { return lockWithApproval_1.lockWithApproval; } });
|
|
48
52
|
var increase_1 = require("./increase");
|
|
49
53
|
Object.defineProperty(exports, "increase", { enumerable: true, get: function () { return increase_1.increase; } });
|
|
54
|
+
var increaseWithApproval_1 = require("./increaseWithApproval");
|
|
55
|
+
Object.defineProperty(exports, "increaseWithApproval", { enumerable: true, get: function () { return increaseWithApproval_1.increaseWithApproval; } });
|
|
50
56
|
var extend_1 = require("./extend");
|
|
51
57
|
Object.defineProperty(exports, "extend", { enumerable: true, get: function () { return extend_1.extend; } });
|
|
52
58
|
var withdraw_1 = require("./withdraw");
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.lockWithApproval = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const getContractAddress_1 = require("../../getContractAddress");
|
|
9
|
+
const getAllowance_1 = __importDefault(require("../../../wallet/assets/getAllowance"));
|
|
10
|
+
const approveAsset_1 = __importDefault(require("../../../wallet/assets/approveAsset"));
|
|
11
|
+
const lock_1 = require("./lock");
|
|
12
|
+
/**
|
|
13
|
+
* Locks RAAC tokens, auto-approving the veRAAC contract first if the current
|
|
14
|
+
* allowance is insufficient. Convenience wrapper so callers don't have to
|
|
15
|
+
* orchestrate the approve+lock dance themselves.
|
|
16
|
+
*
|
|
17
|
+
* @param chainId - The chain/network to use.
|
|
18
|
+
* @param amount - The amount of RAAC tokens to lock (decimal string).
|
|
19
|
+
* @param epochs - Number of epochs to lock tokens for.
|
|
20
|
+
* @param signer - An ethers.js Signer (must be connected to wallet).
|
|
21
|
+
* @returns Transaction receipt of the lock tx.
|
|
22
|
+
*/
|
|
23
|
+
const lockWithApproval = async (chainId, amount, epochs, signer) => {
|
|
24
|
+
if (!signer) {
|
|
25
|
+
throw new Error("Signer is required");
|
|
26
|
+
}
|
|
27
|
+
const userAddress = await signer.getAddress();
|
|
28
|
+
const veRaacAddress = (0, getContractAddress_1.getContractAddress)(chainId, "veraac");
|
|
29
|
+
const amountWei = ethers_1.ethers.parseEther(amount);
|
|
30
|
+
// Check allowance via read-only provider to avoid needing a connected provider
|
|
31
|
+
// on the signer itself — some wrapped signers (e.g. thirdweb) don't expose one.
|
|
32
|
+
const allowance = await (0, getAllowance_1.default)(chainId, "raactoken", userAddress, veRaacAddress, signer.provider ?? undefined);
|
|
33
|
+
if (allowance < amountWei) {
|
|
34
|
+
console.log("[lockWithApproval] Approving RAAC for veRAAC contract…");
|
|
35
|
+
await (0, approveAsset_1.default)(chainId, "raactoken", veRaacAddress, amount, signer);
|
|
36
|
+
console.log("[lockWithApproval] Approval successful");
|
|
37
|
+
}
|
|
38
|
+
return (0, lock_1.lock)(chainId, amountWei, epochs, signer);
|
|
39
|
+
};
|
|
40
|
+
exports.lockWithApproval = lockWithApproval;
|
|
@@ -177,6 +177,9 @@ import { distributeRewards as veRAACDistributeRewards } from "./contracts/tokens
|
|
|
177
177
|
import { getUserPointHistory as getVeRAACUserPointHistory } from "./contracts/tokens/veRAAC/getUserPointHistory";
|
|
178
178
|
import { getCheckpoint as getVeRAACCheckpoint } from "./contracts/tokens/veRAAC/getCheckpoint";
|
|
179
179
|
import { getRagequitRequest as getVeRAACRagequitRequest } from "./contracts/tokens/veRAAC/getRagequitRequest";
|
|
180
|
+
import { getRagequitEpochs as getVeRAACRagequitEpochs } from "./contracts/tokens/veRAAC/getRagequitEpochs";
|
|
181
|
+
import { lockWithApproval as veRAACLockWithApproval } from "./contracts/tokens/veRAAC/lockWithApproval";
|
|
182
|
+
import { increaseWithApproval as veRAACIncreaseWithApproval } from "./contracts/tokens/veRAAC/increaseWithApproval";
|
|
180
183
|
import { getRawBalanceOf as getVeRAACRawBalanceOf } from "./contracts/tokens/veRAAC/getRawBalanceOf";
|
|
181
184
|
import { getRawTotalSupply as getVeRAACRawTotalSupply } from "./contracts/tokens/veRAAC/getRawTotalSupply";
|
|
182
185
|
import { getEffectiveLockEnd as getVeRAACEffectiveLockEnd } from "./contracts/tokens/veRAAC/getEffectiveLockEnd";
|
|
@@ -376,6 +379,9 @@ declare class RPCLibrary {
|
|
|
376
379
|
getUserPointHistory: typeof getVeRAACUserPointHistory;
|
|
377
380
|
getCheckpoint: typeof getVeRAACCheckpoint;
|
|
378
381
|
getRagequitRequest: typeof getVeRAACRagequitRequest;
|
|
382
|
+
getRagequitEpochs: typeof getVeRAACRagequitEpochs;
|
|
383
|
+
lockWithApproval: typeof veRAACLockWithApproval;
|
|
384
|
+
increaseWithApproval: typeof veRAACIncreaseWithApproval;
|
|
379
385
|
getRawBalanceOf: typeof getVeRAACRawBalanceOf;
|
|
380
386
|
getRawTotalSupply: typeof getVeRAACRawTotalSupply;
|
|
381
387
|
getEffectiveLockEnd: typeof getVeRAACEffectiveLockEnd;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the ragequit cooldown duration (in epochs) from the veRAAC contract.
|
|
5
|
+
* The actual cooldown in seconds is `ragequitEpochs * epochDuration`.
|
|
6
|
+
*
|
|
7
|
+
* @param chainId - The chain/network to use.
|
|
8
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
9
|
+
* @returns Number of epochs the user must wait between ragequit initiation and finalization.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getRagequitEpochs: (chainId: ChainId, provider?: Provider) => Promise<number>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ethers, Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Increases the amount of tokens in an existing lock, auto-approving the veRAAC
|
|
5
|
+
* contract first if the current allowance is insufficient.
|
|
6
|
+
*
|
|
7
|
+
* @param chainId - The chain/network to use.
|
|
8
|
+
* @param amountToAdd - Additional RAAC amount to add to the existing lock (decimal string).
|
|
9
|
+
* @param epochEnd - The epoch end time of the existing lock to increase.
|
|
10
|
+
* @param signer - An ethers.js Signer (must be connected to wallet).
|
|
11
|
+
* @returns Transaction receipt of the increase tx.
|
|
12
|
+
*/
|
|
13
|
+
export declare const increaseWithApproval: (chainId: ChainId, amountToAdd: string, epochEnd: number, signer: Signer) => Promise<ethers.ContractTransactionResponse>;
|
|
@@ -18,9 +18,12 @@ export { getEarned } from "./getEarned";
|
|
|
18
18
|
export { getUserPointHistory, type UserPoint } from "./getUserPointHistory";
|
|
19
19
|
export { getCheckpoint, type Checkpoint } from "./getCheckpoint";
|
|
20
20
|
export { getRagequitRequest, type RagequitRequest } from "./getRagequitRequest";
|
|
21
|
+
export { getRagequitEpochs } from "./getRagequitEpochs";
|
|
21
22
|
export { getMaxUnclaimedDistributions } from "./getMaxUnclaimedDistributions";
|
|
22
23
|
export { lock } from "./lock";
|
|
24
|
+
export { lockWithApproval } from "./lockWithApproval";
|
|
23
25
|
export { increase } from "./increase";
|
|
26
|
+
export { increaseWithApproval } from "./increaseWithApproval";
|
|
24
27
|
export { extend } from "./extend";
|
|
25
28
|
export { withdraw } from "./withdraw";
|
|
26
29
|
export { claimReward } from "./claimReward";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ethers, Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Locks RAAC tokens, auto-approving the veRAAC contract first if the current
|
|
5
|
+
* allowance is insufficient. Convenience wrapper so callers don't have to
|
|
6
|
+
* orchestrate the approve+lock dance themselves.
|
|
7
|
+
*
|
|
8
|
+
* @param chainId - The chain/network to use.
|
|
9
|
+
* @param amount - The amount of RAAC tokens to lock (decimal string).
|
|
10
|
+
* @param epochs - Number of epochs to lock tokens for.
|
|
11
|
+
* @param signer - An ethers.js Signer (must be connected to wallet).
|
|
12
|
+
* @returns Transaction receipt of the lock tx.
|
|
13
|
+
*/
|
|
14
|
+
export declare const lockWithApproval: (chainId: ChainId, amount: string, epochs: number, signer: Signer) => Promise<ethers.ContractTransactionResponse>;
|