@raac/rpc 2.0.0-beta.4 → 2.0.0-beta.6
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 +52 -2
- package/dist/artifacts/mocks/core/tokens/ERC721Mock.sol/ERC721Mock.json +491 -0
- package/dist/configs/chains/11155111.json +2 -2
- package/dist/configs/chains/8453.json +29 -3
- package/dist/contracts/lockers/botLocker/addRewardTokens.js +21 -0
- package/dist/contracts/lockers/botLocker/distributeRewardToken.js +23 -0
- package/dist/contracts/lockers/botLocker/getConfig.js +29 -0
- package/dist/contracts/lockers/botLocker/getLocks.js +11 -1
- package/dist/contracts/lockers/botLocker/getRoles.js +22 -0
- package/dist/contracts/lockers/botLocker/getUnlockWindow.js +29 -0
- package/dist/contracts/lockers/botLocker/grantRole.js +38 -0
- package/dist/contracts/lockers/botLocker/hasRole.js +18 -0
- package/dist/contracts/lockers/botLocker/pause.js +24 -0
- package/dist/contracts/lockers/botLocker/rescueTokens.js +22 -0
- package/dist/contracts/zeno/_helpers.js +43 -0
- package/dist/contracts/zeno/buy.js +27 -0
- package/dist/contracts/zeno/getAuctionState.js +45 -0
- package/dist/contracts/zeno/getAuctions.js +7 -4
- package/dist/contracts/zeno/getBondState.js +47 -0
- package/dist/contracts/zeno/getPrice.js +23 -0
- package/dist/contracts/zeno/getZenos.js +6 -6
- package/dist/contracts/zeno/grantRole.js +46 -0
- package/dist/contracts/zeno/pause.js +42 -0
- package/dist/contracts/zeno/priceAt.js +20 -0
- package/dist/contracts/zeno/quoteBuy.js +33 -0
- package/dist/contracts/zeno/redeem.js +44 -0
- package/dist/contracts/zeno/setAuction.js +25 -0
- package/dist/contracts/zeno/sweepSurplus.js +26 -0
- package/dist/nfts/getNFTBalance.js +29 -0
- package/dist/nfts/transferNFT.js +34 -0
- package/dist/types/RPCLibrary.d.ts +51 -1
- package/dist/types/contracts/lockers/botLocker/addRewardTokens.d.ts +11 -0
- package/dist/types/contracts/lockers/botLocker/distributeRewardToken.d.ts +13 -0
- package/dist/types/contracts/lockers/botLocker/getConfig.d.ts +20 -0
- package/dist/types/contracts/lockers/botLocker/getLocks.d.ts +4 -0
- package/dist/types/contracts/lockers/botLocker/getRoles.d.ts +20 -0
- package/dist/types/contracts/lockers/botLocker/getUnlockWindow.d.ts +24 -0
- package/dist/types/contracts/lockers/botLocker/grantRole.d.ts +20 -0
- package/dist/types/contracts/lockers/botLocker/hasRole.d.ts +12 -0
- package/dist/types/contracts/lockers/botLocker/pause.d.ts +6 -0
- package/dist/types/contracts/lockers/botLocker/rescueTokens.d.ts +12 -0
- package/dist/types/contracts/zeno/_helpers.d.ts +17 -0
- package/dist/types/contracts/zeno/buy.d.ts +15 -0
- package/dist/types/contracts/zeno/getAuctionState.d.ts +45 -0
- package/dist/types/contracts/zeno/getAuctions.d.ts +3 -2
- package/dist/types/contracts/zeno/getBondState.d.ts +42 -0
- package/dist/types/contracts/zeno/getPrice.d.ts +12 -0
- package/dist/types/contracts/zeno/getZenos.d.ts +2 -2
- package/dist/types/contracts/zeno/grantRole.d.ts +22 -0
- package/dist/types/contracts/zeno/pause.d.ts +18 -0
- package/dist/types/contracts/zeno/priceAt.d.ts +20 -0
- package/dist/types/contracts/zeno/quoteBuy.d.ts +34 -0
- package/dist/types/contracts/zeno/redeem.d.ts +20 -0
- package/dist/types/contracts/zeno/setAuction.d.ts +13 -0
- package/dist/types/contracts/zeno/sweepSurplus.d.ts +14 -0
- package/dist/types/nfts/getNFTBalance.d.ts +13 -0
- package/dist/types/nfts/transferNFT.d.ts +15 -0
- package/dist/types/utils/artifacts.d.ts +99 -0
- package/dist/utils/artifacts.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pause = pause;
|
|
4
|
+
exports.unpause = unpause;
|
|
5
|
+
const rpcError_1 = require("../../utils/rpcError");
|
|
6
|
+
const _helpers_1 = require("./_helpers");
|
|
7
|
+
/**
|
|
8
|
+
* Halts `buy` on an auction. PAUSER_ROLE only. A Dutch price keeps falling while paused.
|
|
9
|
+
* @param chainId The chain id.
|
|
10
|
+
* @param auction The auction address.
|
|
11
|
+
* @param signer A PAUSER_ROLE holder.
|
|
12
|
+
* @returns The transaction receipt.
|
|
13
|
+
*/
|
|
14
|
+
async function pause(chainId, auction, signer) {
|
|
15
|
+
if (!signer)
|
|
16
|
+
throw new Error("Signer is required");
|
|
17
|
+
try {
|
|
18
|
+
const tx = await (0, _helpers_1.getAuctionContract)(chainId, auction, signer).pause();
|
|
19
|
+
return await tx.wait();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw (0, rpcError_1.toRpcError)("zeno.pause", error, { chainId, address: auction });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resumes `buy` on an auction. DEFAULT_ADMIN_ROLE only, so a compromised pauser cannot reopen buying.
|
|
27
|
+
* @param chainId The chain id.
|
|
28
|
+
* @param auction The auction address.
|
|
29
|
+
* @param signer A DEFAULT_ADMIN_ROLE holder.
|
|
30
|
+
* @returns The transaction receipt.
|
|
31
|
+
*/
|
|
32
|
+
async function unpause(chainId, auction, signer) {
|
|
33
|
+
if (!signer)
|
|
34
|
+
throw new Error("Signer is required");
|
|
35
|
+
try {
|
|
36
|
+
const tx = await (0, _helpers_1.getAuctionContract)(chainId, auction, signer).unpause();
|
|
37
|
+
return await tx.wait();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw (0, rpcError_1.toRpcError)("zeno.unpause", error, { chainId, address: auction });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.priceAt = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An auction's price at `now`, computed locally without an RPC call. Mirrors `Auction.getPrice()` exactly, truncating
|
|
6
|
+
* division included: the starting price before the window, the reserve from `endTime` on, a linear fall between.
|
|
7
|
+
*
|
|
8
|
+
* @param terms The auction's price terms, e.g. from `getAuctionState` or the subgraph's `BondAuction`.
|
|
9
|
+
* @param now UNIX timestamp (seconds). Use the latest block timestamp to match the contract exactly.
|
|
10
|
+
* @returns The price in payment token base units per whole ZENO.
|
|
11
|
+
*/
|
|
12
|
+
const priceAt = (terms, now) => {
|
|
13
|
+
if (now < terms.startTime)
|
|
14
|
+
return terms.startingPrice;
|
|
15
|
+
if (now >= terms.endTime)
|
|
16
|
+
return terms.reservePrice;
|
|
17
|
+
return (terms.startingPrice -
|
|
18
|
+
((terms.startingPrice - terms.reservePrice) * (now - terms.startTime)) / (terms.endTime - terms.startTime));
|
|
19
|
+
};
|
|
20
|
+
exports.priceAt = priceAt;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quoteBuy = void 0;
|
|
4
|
+
const BPS = 10000n;
|
|
5
|
+
/**
|
|
6
|
+
* What a buy mints, computed locally without an RPC call with `Auction.buy`'s integer maths:
|
|
7
|
+
* `zenoOut = paymentAmount * 10^zenoDecimals / price`, truncated.
|
|
8
|
+
*
|
|
9
|
+
* A Dutch price only falls, so a buy mined after the quote mints at least `zenoOut`; `minZenoOut` guards against a
|
|
10
|
+
* fixed price or a stale quote. The same fall means a payment at exactly `maxPayment` can revert a block later, so
|
|
11
|
+
* leave headroom when buying out the remainder.
|
|
12
|
+
*
|
|
13
|
+
* @param input The price, payment, ZENO decimals, remaining supply and slippage tolerance.
|
|
14
|
+
* @returns The ZENO out, the `minZenoOut` to send, and the payment ceiling.
|
|
15
|
+
*/
|
|
16
|
+
const quoteBuy = (input) => {
|
|
17
|
+
if (input.price <= 0n)
|
|
18
|
+
throw new Error("Price must be positive");
|
|
19
|
+
const slippageBps = input.slippageBps ?? 0n;
|
|
20
|
+
if (slippageBps < 0n || slippageBps > BPS)
|
|
21
|
+
throw new Error("Slippage must be between 0 and 10000 bps");
|
|
22
|
+
const scale = 10n ** BigInt(input.zenoDecimals);
|
|
23
|
+
const zenoOut = (input.paymentAmount * scale) / input.price;
|
|
24
|
+
// floor(p * scale / price) <= remaining <=> p * scale < (remaining + 1) * price
|
|
25
|
+
const maxPayment = ((input.totalRemaining + 1n) * input.price - 1n) / scale;
|
|
26
|
+
return {
|
|
27
|
+
zenoOut,
|
|
28
|
+
minZenoOut: (zenoOut * (BPS - slippageBps)) / BPS,
|
|
29
|
+
maxPayment,
|
|
30
|
+
exceedsRemaining: input.paymentAmount > maxPayment,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.quoteBuy = quoteBuy;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redeem = redeem;
|
|
4
|
+
exports.redeemAll = redeemAll;
|
|
5
|
+
const rpcError_1 = require("../../utils/rpcError");
|
|
6
|
+
const _helpers_1 = require("./_helpers");
|
|
7
|
+
/**
|
|
8
|
+
* Redeems ZENO 1:1 for the underlying. Reverts before maturity, and while the bond's collateral is short of its
|
|
9
|
+
* outstanding supply (`getBondState(...).isFunded`).
|
|
10
|
+
* @param chainId The chain id.
|
|
11
|
+
* @param zeno The ZENO bond address.
|
|
12
|
+
* @param amount ZENO to redeem, in base units.
|
|
13
|
+
* @param signer The holder, who receives the underlying.
|
|
14
|
+
* @returns The transaction receipt.
|
|
15
|
+
*/
|
|
16
|
+
async function redeem(chainId, zeno, amount, signer) {
|
|
17
|
+
if (!signer)
|
|
18
|
+
throw new Error("Signer is required");
|
|
19
|
+
try {
|
|
20
|
+
const tx = await (0, _helpers_1.getZenoContract)(chainId, zeno, signer).redeem(amount);
|
|
21
|
+
return await tx.wait();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw (0, rpcError_1.toRpcError)("zeno.redeem", error, { chainId, address: zeno });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Redeems the signer's whole ZENO balance for the underlying. Same conditions as `redeem`.
|
|
29
|
+
* @param chainId The chain id.
|
|
30
|
+
* @param zeno The ZENO bond address.
|
|
31
|
+
* @param signer The holder, who receives the underlying.
|
|
32
|
+
* @returns The transaction receipt.
|
|
33
|
+
*/
|
|
34
|
+
async function redeemAll(chainId, zeno, signer) {
|
|
35
|
+
if (!signer)
|
|
36
|
+
throw new Error("Signer is required");
|
|
37
|
+
try {
|
|
38
|
+
const tx = await (0, _helpers_1.getZenoContract)(chainId, zeno, signer).redeemAll();
|
|
39
|
+
return await tx.wait();
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw (0, rpcError_1.toRpcError)("zeno.redeemAll", error, { chainId, address: zeno });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rpcError_1 = require("../../utils/rpcError");
|
|
4
|
+
const _helpers_1 = require("./_helpers");
|
|
5
|
+
/**
|
|
6
|
+
* Binds a ZENO to the auction that sells it. One-shot, ZENO owner only; reverts unless the auction's `zeno()` points
|
|
7
|
+
* back at this ZENO. Until it is set, the auction's buys revert.
|
|
8
|
+
* @param chainId The chain id.
|
|
9
|
+
* @param zeno The ZENO bond address.
|
|
10
|
+
* @param auction The auction created for it.
|
|
11
|
+
* @param signer The ZENO owner.
|
|
12
|
+
* @returns The transaction receipt.
|
|
13
|
+
*/
|
|
14
|
+
async function setAuction(chainId, zeno, auction, signer) {
|
|
15
|
+
if (!signer)
|
|
16
|
+
throw new Error("Signer is required");
|
|
17
|
+
try {
|
|
18
|
+
const tx = await (0, _helpers_1.getZenoContract)(chainId, zeno, signer).setAuction(auction);
|
|
19
|
+
return await tx.wait();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw (0, rpcError_1.toRpcError)("zeno.setAuction", error, { chainId, address: zeno });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = setAuction;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rpcError_1 = require("../../utils/rpcError");
|
|
4
|
+
const _helpers_1 = require("./_helpers");
|
|
5
|
+
/**
|
|
6
|
+
* Sweeps underlying held above the ZENO's outstanding supply: unsold prefill, overpayments and post-maturity residue.
|
|
7
|
+
* ZENO owner only, and only once the bound auction has ended. `getBondState(...).sweepableSurplus` is the most it takes.
|
|
8
|
+
* @param chainId The chain id.
|
|
9
|
+
* @param zeno The ZENO bond address.
|
|
10
|
+
* @param to The recipient of the underlying.
|
|
11
|
+
* @param amount Underlying to sweep, in base units.
|
|
12
|
+
* @param signer The ZENO owner.
|
|
13
|
+
* @returns The transaction receipt.
|
|
14
|
+
*/
|
|
15
|
+
async function sweepSurplus(chainId, zeno, to, amount, signer) {
|
|
16
|
+
if (!signer)
|
|
17
|
+
throw new Error("Signer is required");
|
|
18
|
+
try {
|
|
19
|
+
const tx = await (0, _helpers_1.getZenoContract)(chainId, zeno, signer).sweepSurplus(to, amount);
|
|
20
|
+
return await tx.wait();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw (0, rpcError_1.toRpcError)("zeno.sweepSurplus", error, { chainId, address: zeno });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = sweepSurplus;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
+
const rpcError_1 = require("../utils/rpcError");
|
|
7
|
+
/**
|
|
8
|
+
* Get how many tokens of an NFT contract an address holds
|
|
9
|
+
* @param chainId - The chain ID
|
|
10
|
+
* @param nftContractName - The NFT contract name from configs
|
|
11
|
+
* @param owner - The address to check
|
|
12
|
+
* @param provider - The provider to use for the contract call
|
|
13
|
+
* @returns The number of tokens held
|
|
14
|
+
*/
|
|
15
|
+
async function getNFTBalance(chainId, nftContractName, owner, provider) {
|
|
16
|
+
if (!provider) {
|
|
17
|
+
throw new Error("Provider not available");
|
|
18
|
+
}
|
|
19
|
+
const nftAddress = (0, contracts_1.getContractAddress)(chainId, nftContractName);
|
|
20
|
+
try {
|
|
21
|
+
const nftABI = (0, artifacts_1.getABI)(nftContractName);
|
|
22
|
+
const nftContract = new ethers_1.ethers.Contract(nftAddress, nftABI, provider);
|
|
23
|
+
return await nftContract.balanceOf(owner);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw (0, rpcError_1.toRpcError)("nfts.getNFTBalance", error, { chainId, address: nftAddress });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = getNFTBalance;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ethers_1 = require("ethers");
|
|
4
|
+
const contracts_1 = require("../utils/contracts");
|
|
5
|
+
const artifacts_1 = require("../utils/artifacts");
|
|
6
|
+
const rpcError_1 = require("../utils/rpcError");
|
|
7
|
+
/**
|
|
8
|
+
* Transfer an NFT from the signer to another address with safeTransferFrom
|
|
9
|
+
* Do not use it to put a Bot NFT into the bot locker: the locker only records NFTs deposited through `lockers.botLocker.lock`.
|
|
10
|
+
* @param chainId - The chain ID
|
|
11
|
+
* @param nftContractName - The NFT contract name from configs
|
|
12
|
+
* @param to - The recipient address
|
|
13
|
+
* @param tokenId - The token ID to transfer
|
|
14
|
+
* @param signer - The signer that owns the token
|
|
15
|
+
* @returns Transaction receipt
|
|
16
|
+
*/
|
|
17
|
+
async function transferNFT(chainId, nftContractName, to, tokenId, signer) {
|
|
18
|
+
if (!signer) {
|
|
19
|
+
throw new Error("Wallet not connected");
|
|
20
|
+
}
|
|
21
|
+
const nftAddress = (0, contracts_1.getContractAddress)(chainId, nftContractName);
|
|
22
|
+
try {
|
|
23
|
+
const nftABI = (0, artifacts_1.getABI)(nftContractName);
|
|
24
|
+
const nftContract = new ethers_1.ethers.Contract(nftAddress, nftABI, signer);
|
|
25
|
+
const from = await signer.getAddress();
|
|
26
|
+
const tx = await nftContract["safeTransferFrom(address,address,uint256)"](from, to, tokenId);
|
|
27
|
+
const receipt = await tx.wait();
|
|
28
|
+
return receipt;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw (0, rpcError_1.toRpcError)("nfts.transferNFT", error, { chainId, address: nftAddress });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = transferNFT;
|
|
@@ -74,6 +74,17 @@ import getAuctions from "./contracts/zeno/getAuctions";
|
|
|
74
74
|
import createAuction from "./contracts/zeno/createAuction";
|
|
75
75
|
import createZeno from "./contracts/zeno/createZeno";
|
|
76
76
|
import getZenos from "./contracts/zeno/getZenos";
|
|
77
|
+
import getAuctionState from "./contracts/zeno/getAuctionState";
|
|
78
|
+
import getBondState from "./contracts/zeno/getBondState";
|
|
79
|
+
import getAuctionPrice from "./contracts/zeno/getPrice";
|
|
80
|
+
import buyZeno from "./contracts/zeno/buy";
|
|
81
|
+
import { redeem as redeemZeno, redeemAll as redeemAllZeno } from "./contracts/zeno/redeem";
|
|
82
|
+
import setAuction from "./contracts/zeno/setAuction";
|
|
83
|
+
import sweepSurplus from "./contracts/zeno/sweepSurplus";
|
|
84
|
+
import { pause as pauseAuction, unpause as unpauseAuction } from "./contracts/zeno/pause";
|
|
85
|
+
import { grantRole as grantRoleAuction, revokeRole as revokeRoleAuction } from "./contracts/zeno/grantRole";
|
|
86
|
+
import { priceAt } from "./contracts/zeno/priceAt";
|
|
87
|
+
import { quoteBuy } from "./contracts/zeno/quoteBuy";
|
|
77
88
|
import { ChainId } from "./configs/chains";
|
|
78
89
|
import getBaseUri from "./nfts/getBaseUri";
|
|
79
90
|
import claimRewardFromPool from "./contracts/feeCollector/claimRewardFromPool";
|
|
@@ -106,6 +117,8 @@ import getNFTApproval from "./nfts/getNFTApproval";
|
|
|
106
117
|
import getApprovedForAll from "./nfts/getApprovalForAll";
|
|
107
118
|
import setApprovalForAll from "./nfts/setApprovalForAll";
|
|
108
119
|
import approveNFT from "./nfts/approveNFT";
|
|
120
|
+
import getNFTBalance from "./nfts/getNFTBalance";
|
|
121
|
+
import transferNFT from "./nfts/transferNFT";
|
|
109
122
|
import vaultOpened from "./pools/lendingPool/vaultOpened";
|
|
110
123
|
import { getWithdrawRequestInfo as getStabilityPoolWithdrawRequestInfo } from "./pools/stabilityPool/getWithdrawRequestInfo";
|
|
111
124
|
import { getWithdrawTimelockConfig as getStabilityPoolWithdrawTimelockConfig } from "./pools/stabilityPool/getWithdrawTimelockConfig";
|
|
@@ -242,8 +255,17 @@ import { getClaimables as getClaimablesBotLocker } from "./contracts/lockers/bot
|
|
|
242
255
|
import { getClaimedRewards as getClaimedRewardsBotLocker } from "./contracts/lockers/botLocker/getClaimedRewards";
|
|
243
256
|
import { getRewardTokens as getRewardTokensBotLocker } from "./contracts/lockers/botLocker/getRewardTokens";
|
|
244
257
|
import { getRewardTokenCount as getRewardTokenCountBotLocker } from "./contracts/lockers/botLocker/getRewardTokenCount";
|
|
245
|
-
import { getLocks as getLocksBotLocker, getLocksByOwner as getLocksByOwnerBotLocker } from "./contracts/lockers/botLocker/getLocks";
|
|
258
|
+
import { getLocks as getLocksBotLocker, getLock as getLockBotLocker, getLocksByOwner as getLocksByOwnerBotLocker } from "./contracts/lockers/botLocker/getLocks";
|
|
246
259
|
import { getLockedTokenIds as getLockedTokenIdsBotLocker } from "./contracts/lockers/botLocker/getLockedTokenIds";
|
|
260
|
+
import { getConfig as getConfigBotLocker } from "./contracts/lockers/botLocker/getConfig";
|
|
261
|
+
import { getUnlockWindow as getUnlockWindowBotLocker } from "./contracts/lockers/botLocker/getUnlockWindow";
|
|
262
|
+
import { getRoles as getRolesBotLocker } from "./contracts/lockers/botLocker/getRoles";
|
|
263
|
+
import { hasRole as hasRoleBotLocker } from "./contracts/lockers/botLocker/hasRole";
|
|
264
|
+
import { grantRole as grantRoleBotLocker, revokeRole as revokeRoleBotLocker } from "./contracts/lockers/botLocker/grantRole";
|
|
265
|
+
import { addRewardTokens as addRewardTokensBotLocker } from "./contracts/lockers/botLocker/addRewardTokens";
|
|
266
|
+
import { distributeRewardToken as distributeRewardTokenBotLocker } from "./contracts/lockers/botLocker/distributeRewardToken";
|
|
267
|
+
import { pause as pauseBotLocker, unpause as unpauseBotLocker } from "./contracts/lockers/botLocker/pause";
|
|
268
|
+
import { rescueTokens as rescueTokensBotLocker } from "./contracts/lockers/botLocker/rescueTokens";
|
|
247
269
|
import { getBalance as getLeRAACBalance } from "./contracts/tokens/leRAAC/getBalance";
|
|
248
270
|
import { getTotalSupply as getLeRAACTotalSupply } from "./contracts/tokens/leRAAC/getTotalSupply";
|
|
249
271
|
import { getAllowance as getLeRAACAllowance } from "./contracts/tokens/leRAAC/getAllowance";
|
|
@@ -337,6 +359,8 @@ declare class RPCLibrary {
|
|
|
337
359
|
getApprovedForAll: typeof getApprovedForAll;
|
|
338
360
|
setApprovalForAll: typeof setApprovalForAll;
|
|
339
361
|
approveNFT: typeof approveNFT;
|
|
362
|
+
getNFTBalance: typeof getNFTBalance;
|
|
363
|
+
transferNFT: typeof transferNFT;
|
|
340
364
|
};
|
|
341
365
|
contracts: {
|
|
342
366
|
housePrices: {
|
|
@@ -549,8 +573,20 @@ declare class RPCLibrary {
|
|
|
549
573
|
getRewardTokens: typeof getRewardTokensBotLocker;
|
|
550
574
|
getRewardTokenCount: typeof getRewardTokenCountBotLocker;
|
|
551
575
|
getLocks: typeof getLocksBotLocker;
|
|
576
|
+
getLock: typeof getLockBotLocker;
|
|
552
577
|
getLocksByOwner: typeof getLocksByOwnerBotLocker;
|
|
553
578
|
getLockedTokenIds: typeof getLockedTokenIdsBotLocker;
|
|
579
|
+
getConfig: typeof getConfigBotLocker;
|
|
580
|
+
getUnlockWindow: typeof getUnlockWindowBotLocker;
|
|
581
|
+
getRoles: typeof getRolesBotLocker;
|
|
582
|
+
hasRole: typeof hasRoleBotLocker;
|
|
583
|
+
grantRole: typeof grantRoleBotLocker;
|
|
584
|
+
revokeRole: typeof revokeRoleBotLocker;
|
|
585
|
+
addRewardTokens: typeof addRewardTokensBotLocker;
|
|
586
|
+
distributeRewardToken: typeof distributeRewardTokenBotLocker;
|
|
587
|
+
pause: typeof pauseBotLocker;
|
|
588
|
+
unpause: typeof unpauseBotLocker;
|
|
589
|
+
rescueTokens: typeof rescueTokensBotLocker;
|
|
554
590
|
};
|
|
555
591
|
};
|
|
556
592
|
zap: {
|
|
@@ -671,6 +707,20 @@ declare class RPCLibrary {
|
|
|
671
707
|
getAuctions: typeof getAuctions;
|
|
672
708
|
createZeno: typeof createZeno;
|
|
673
709
|
getZenos: typeof getZenos;
|
|
710
|
+
getAuctionState: typeof getAuctionState;
|
|
711
|
+
getBondState: typeof getBondState;
|
|
712
|
+
getPrice: typeof getAuctionPrice;
|
|
713
|
+
buy: typeof buyZeno;
|
|
714
|
+
redeem: typeof redeemZeno;
|
|
715
|
+
redeemAll: typeof redeemAllZeno;
|
|
716
|
+
setAuction: typeof setAuction;
|
|
717
|
+
sweepSurplus: typeof sweepSurplus;
|
|
718
|
+
pause: typeof pauseAuction;
|
|
719
|
+
unpause: typeof unpauseAuction;
|
|
720
|
+
grantRole: typeof grantRoleAuction;
|
|
721
|
+
revokeRole: typeof revokeRoleAuction;
|
|
722
|
+
priceAt: typeof priceAt;
|
|
723
|
+
quoteBuy: typeof quoteBuy;
|
|
674
724
|
};
|
|
675
725
|
provider: any;
|
|
676
726
|
estimateGasPrice: any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Register reward tokens that can be distributed to lockers. MANAGER_ROLE only.
|
|
5
|
+
* Reverts if any token is the zero address or already registered.
|
|
6
|
+
*
|
|
7
|
+
* @param chainId - The chain/network to use.
|
|
8
|
+
* @param tokens - ERC20 addresses to register.
|
|
9
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
10
|
+
*/
|
|
11
|
+
export declare const addRewardTokens: (chainId: ChainId, tokens: string[], signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Distribute `amount` of a registered reward token across all currently locked NFTs. DISTRIBUTOR_ROLE only.
|
|
5
|
+
* The signer's tokens are pulled via transferFrom, so approve the locker for `amount` first.
|
|
6
|
+
* Reverts when nothing is locked.
|
|
7
|
+
*
|
|
8
|
+
* @param chainId - The chain/network to use.
|
|
9
|
+
* @param token - Address of a registered reward token.
|
|
10
|
+
* @param amount - Amount to distribute, in `token` base units.
|
|
11
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
12
|
+
*/
|
|
13
|
+
export declare const distributeRewardToken: (chainId: ChainId, token: string, amount: bigint, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
export interface BotLockerConfig {
|
|
4
|
+
/** Address of the RAAC Bot NFT collection the locker accepts. */
|
|
5
|
+
nft: string;
|
|
6
|
+
/** Length of one epoch, seconds (EPOCH_DURATION). */
|
|
7
|
+
epochDuration: number;
|
|
8
|
+
/** Epochs per lock cycle; an NFT can unlock when its locked epochs are a non-zero multiple of this (LOCK_DURATION_IN_EPOCH). */
|
|
9
|
+
lockDurationEpochs: number;
|
|
10
|
+
rewardTokens: string[];
|
|
11
|
+
paused: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read the locker's configuration in a single call batch.
|
|
15
|
+
*
|
|
16
|
+
* @param chainId - The chain/network to use.
|
|
17
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
18
|
+
* @returns The NFT collection, lock timing constants, reward tokens and pause state.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getConfig: (chainId: ChainId, provider?: Provider) => Promise<BotLockerConfig>;
|
|
@@ -9,6 +9,10 @@ export interface BotLockerNFTLock {
|
|
|
9
9
|
* Returns every active NFT lock across all owners.
|
|
10
10
|
*/
|
|
11
11
|
export declare const getLocks: (chainId: ChainId, provider?: Provider) => Promise<BotLockerNFTLock[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the lock of a single NFT, or null when it is not locked.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getLock: (chainId: ChainId, tokenId: string | number | bigint, provider?: Provider) => Promise<BotLockerNFTLock | null>;
|
|
12
16
|
/**
|
|
13
17
|
* Returns every active NFT lock owned by `owner`.
|
|
14
18
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
export interface BotLockerRoles {
|
|
4
|
+
/** Grants and revokes roles, and calls `rescueTokens`. */
|
|
5
|
+
defaultAdminRole: string;
|
|
6
|
+
/** Calls `pause` and `unpause`. */
|
|
7
|
+
pauserRole: string;
|
|
8
|
+
/** Calls `addRewardTokens`. */
|
|
9
|
+
managerRole: string;
|
|
10
|
+
/** Calls `distributeRewardToken`; held by RAACLiquidLocker. */
|
|
11
|
+
distributorRole: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Gets the access-control role identifiers used by the bot locker.
|
|
15
|
+
*
|
|
16
|
+
* @param chainId - The chain/network to use.
|
|
17
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
18
|
+
* @returns The bytes32 role identifiers.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getRoles: (chainId: ChainId, provider?: Provider) => Promise<BotLockerRoles>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** EPOCH_DURATION on RAACBotLocker, seconds. */
|
|
2
|
+
export declare const BOT_LOCKER_EPOCH_DURATION: number;
|
|
3
|
+
/** LOCK_DURATION_IN_EPOCH on RAACBotLocker. */
|
|
4
|
+
export declare const BOT_LOCKER_LOCK_DURATION_EPOCHS = 4;
|
|
5
|
+
export interface BotLockerUnlockWindow {
|
|
6
|
+
/** True when `now` is inside an unlock window. */
|
|
7
|
+
unlockable: boolean;
|
|
8
|
+
/** Start of the current window when unlockable, otherwise of the next one, unix seconds. */
|
|
9
|
+
opensAt: number;
|
|
10
|
+
/** End (exclusive) of that window, unix seconds. */
|
|
11
|
+
closesAt: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Unlock window of a locked NFT, computed locally without an RPC call.
|
|
15
|
+
*
|
|
16
|
+
* The contract allows `unlockAndClaim` when `floor((now - lockedAt) / epochDuration)` is a non-zero multiple of `lockDurationEpochs`, so windows are `[lockedAt + k * cycle, lockedAt + k * cycle + epochDuration)` for `k >= 1`, where `cycle = lockDurationEpochs * epochDuration`. They are relative to each NFT's own `lockedAt`, not to a global epoch, and a missed window reopens one cycle later.
|
|
17
|
+
*
|
|
18
|
+
* @param lockedAt - Lock timestamp of the NFT, unix seconds (`locks(tokenId).lockedAt`, or `lockedAt` from the subgraph).
|
|
19
|
+
* @param now - Current time, unix seconds. Use the latest block timestamp to match the contract exactly.
|
|
20
|
+
* @param epochDuration - Epoch length, seconds. Defaults to the contract constant.
|
|
21
|
+
* @param lockDurationEpochs - Epochs per lock cycle. Defaults to the contract constant.
|
|
22
|
+
* @returns Whether the NFT can unlock now and the bounds of the current or next window.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getUnlockWindow: (lockedAt: number, now: number, epochDuration?: number, lockDurationEpochs?: number) => BotLockerUnlockWindow;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Grant a bot locker role. DEFAULT_ADMIN_ROLE only.
|
|
5
|
+
*
|
|
6
|
+
* @param chainId - The chain/network to use.
|
|
7
|
+
* @param role - The bytes32 role identifier (see `getRoles`).
|
|
8
|
+
* @param account - The address to grant the role to.
|
|
9
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
10
|
+
*/
|
|
11
|
+
export declare const grantRole: (chainId: ChainId, role: string, account: string, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* Revoke a bot locker role. DEFAULT_ADMIN_ROLE only.
|
|
14
|
+
*
|
|
15
|
+
* @param chainId - The chain/network to use.
|
|
16
|
+
* @param role - The bytes32 role identifier (see `getRoles`).
|
|
17
|
+
* @param account - The address to revoke the role from.
|
|
18
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
19
|
+
*/
|
|
20
|
+
export declare const revokeRole: (chainId: ChainId, role: string, account: string, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether an account holds a bot locker role.
|
|
5
|
+
*
|
|
6
|
+
* @param chainId - The chain/network to use.
|
|
7
|
+
* @param role - The bytes32 role identifier (see `getRoles`).
|
|
8
|
+
* @param account - The address to check.
|
|
9
|
+
* @param provider - Optional ethers.js Provider instance.
|
|
10
|
+
* @returns True if the account holds the role.
|
|
11
|
+
*/
|
|
12
|
+
export declare const hasRole: (chainId: ChainId, role: string, account: string, provider?: Provider) => Promise<boolean>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/** Pause lock, unlockAndClaim and claim. PAUSER_ROLE only. */
|
|
4
|
+
export declare const pause: (chainId: ChainId, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
5
|
+
/** PAUSER_ROLE only. */
|
|
6
|
+
export declare const unpause: (chainId: ChainId, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Send the locker's entire balance of `token` to `recipient`. DEFAULT_ADMIN_ROLE only.
|
|
5
|
+
* This includes rewards lockers have not claimed yet, so later claims of that token revert until it is refilled.
|
|
6
|
+
*
|
|
7
|
+
* @param chainId - The chain/network to use.
|
|
8
|
+
* @param token - ERC20 address to rescue.
|
|
9
|
+
* @param recipient - Address receiving the balance.
|
|
10
|
+
* @param signer - An ethers.js Signer instance (required).
|
|
11
|
+
*/
|
|
12
|
+
export declare const rescueTokens: (chainId: ChainId, token: string, recipient: string, signer: Signer) => Promise<import("ethers").ContractTransactionResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Provider, Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../configs/chains";
|
|
3
|
+
import { TokenAmount } from "../../utils/amount";
|
|
4
|
+
import { Auction, ZENO } from "../../typechain-types";
|
|
5
|
+
/** The one ERC20 call the zeno methods make: the underlying held by a ZENO. */
|
|
6
|
+
export declare const ERC20_ABI: string[];
|
|
7
|
+
/** A ZENO bond. Bonds are created by the factory, so the address is passed in rather than read from the config. */
|
|
8
|
+
export declare function getZenoContract(chainId: ChainId, zeno: string, runner?: Provider | Signer): ZENO;
|
|
9
|
+
/** A ZENO auction. Auctions are created by the factory, so the address is passed in rather than read from the config. */
|
|
10
|
+
export declare function getAuctionContract(chainId: ChainId, auction: string, runner?: Provider | Signer): Auction;
|
|
11
|
+
/**
|
|
12
|
+
* A ZENO amount. ZENO takes its decimals from its underlying, so they come from the underlying's registry entry; a
|
|
13
|
+
* ZENO address itself is never in the registry. Falls back to 18 decimals when the underlying is not listed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toZenoAmount(chainId: ChainId, underlying: string, value: bigint, symbol?: string): TokenAmount;
|
|
16
|
+
/** `ZENO.auction()` and other unset address fields read as the zero address; this maps that to null. */
|
|
17
|
+
export declare function addressOrNull(address: string): string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
|
+
import { ChainId } from "../../configs/chains";
|
|
3
|
+
/**
|
|
4
|
+
* Buys ZENO: spends exactly `paymentAmount` of the payment token, sent to the issuer, at the price of the block it is
|
|
5
|
+
* mined in. Needs a payment token allowance for the auction (`wallet.assets.approveAsset`). Reverts while paused,
|
|
6
|
+
* outside the auction window, when the ZENO out would exceed what is left, or when it is below `minZenoOut`.
|
|
7
|
+
* @param chainId The chain id.
|
|
8
|
+
* @param auction The auction address.
|
|
9
|
+
* @param paymentAmount Payment token to spend, in base units.
|
|
10
|
+
* @param minZenoOut The least ZENO to accept, in ZENO base units; `quoteBuy` sizes it.
|
|
11
|
+
* @param signer The buyer, who receives the ZENO.
|
|
12
|
+
* @returns The transaction receipt; its `ZENOPurchased` log carries the ZENO minted and the price paid.
|
|
13
|
+
*/
|
|
14
|
+
declare function buy(chainId: ChainId, auction: string, paymentAmount: bigint, minZenoOut: bigint, signer: Signer): Promise<import("ethers").ContractTransactionReceipt>;
|
|
15
|
+
export default buy;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../../configs/chains";
|
|
3
|
+
import { TokenAmount } from "../../utils/amount";
|
|
4
|
+
import { FundingMode } from "./createAuction";
|
|
5
|
+
/** A ZENO auction's terms and live state. Prices take the payment token's decimals, ZENO amounts the underlying's. */
|
|
6
|
+
export interface AuctionState {
|
|
7
|
+
/** The auction contract. */
|
|
8
|
+
auction: string;
|
|
9
|
+
/** The ZENO bond it sells. */
|
|
10
|
+
zeno: string;
|
|
11
|
+
/** What buyers pay with. */
|
|
12
|
+
paymentToken: string;
|
|
13
|
+
/** Receives every payment. */
|
|
14
|
+
issuer: string;
|
|
15
|
+
fundingMode: FundingMode;
|
|
16
|
+
/** UNIX timestamp (seconds) buying opens. */
|
|
17
|
+
startTime: bigint;
|
|
18
|
+
/** UNIX timestamp (seconds) buying closes, unless it sells out first. */
|
|
19
|
+
endTime: bigint;
|
|
20
|
+
/** Price at `startTime`, in payment token base units per whole ZENO. */
|
|
21
|
+
startingPrice: TokenAmount;
|
|
22
|
+
/** Price at and after `endTime`; equal to `startingPrice` for a fixed-price bond. */
|
|
23
|
+
reservePrice: TokenAmount;
|
|
24
|
+
/** True when the price does not decay. */
|
|
25
|
+
isFixedPrice: boolean;
|
|
26
|
+
/** `getPrice()` as of the block read. A Dutch price keeps falling every block, also while paused. */
|
|
27
|
+
price: TokenAmount;
|
|
28
|
+
/** ZENO on offer. */
|
|
29
|
+
totalAllocated: TokenAmount;
|
|
30
|
+
/** ZENO not yet sold; `buy` reverts when it would mint more. */
|
|
31
|
+
totalRemaining: TokenAmount;
|
|
32
|
+
/** True while `buy` is halted by the pauser. */
|
|
33
|
+
paused: boolean;
|
|
34
|
+
/** True once past `endTime` or sold out, as `checkAuctionEnded()` says. */
|
|
35
|
+
ended: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads one auction's terms and live state.
|
|
39
|
+
* @param chainId The chain id.
|
|
40
|
+
* @param auction The auction address.
|
|
41
|
+
* @param provider The provider to read with. Defaults to the chain's first configured RPC.
|
|
42
|
+
* @returns The auction's state.
|
|
43
|
+
*/
|
|
44
|
+
declare function getAuctionState(chainId: ChainId, auction: string, provider?: Provider): Promise<AuctionState>;
|
|
45
|
+
export default getAuctionState;
|
|
@@ -33,8 +33,9 @@ export interface AuctionDetails {
|
|
|
33
33
|
* Lists every auction created by the AuctionFactory.
|
|
34
34
|
* @param chainId The chain id.
|
|
35
35
|
* @param provider The provider to read with. Defaults to the chain's first configured RPC.
|
|
36
|
-
* @returns One record per auction. Price amounts use the auction's payment token, ZENO amounts the ZENO
|
|
37
|
-
*
|
|
36
|
+
* @returns One record per auction. Price amounts use the auction's payment token, ZENO amounts the ZENO's underlying,
|
|
37
|
+
* whose decimals ZENO shares; decimals and symbols come from the chain config registry and fall back to 18 when the
|
|
38
|
+
* token is not listed.
|
|
38
39
|
*/
|
|
39
40
|
declare function getAuctions(chainId: ChainId, provider?: Provider): Promise<AuctionDetails[]>;
|
|
40
41
|
export default getAuctions;
|