diff --git a/.changeset/grumpy-bugs-jump.md b/.changeset/grumpy-bugs-jump.md new file mode 100644 index 00000000..6a27a4c1 --- /dev/null +++ b/.changeset/grumpy-bugs-jump.md @@ -0,0 +1,6 @@ +--- +"@enzymefinance/abis": patch +"@enzymefinance/sdk": patch +--- + +Add SingleAssetRedemptionQueue diff --git a/packages/abis/abis/ISingleAssetRedemptionQueueFactory.abi.json b/packages/abis/abis/ISingleAssetRedemptionQueueFactory.abi.json new file mode 100644 index 00000000..b5110bfc --- /dev/null +++ b/packages/abis/abis/ISingleAssetRedemptionQueueFactory.abi.json @@ -0,0 +1,72 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_libAddress", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "deployProxy", + "inputs": [ + { + "name": "_vaultProxy", + "type": "address", + "internalType": "address" + }, + { + "name": "_redemptionAssetAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "_bypassableSharesThreshold", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_managers", + "type": "address[]", + "internalType": "address[]" + } + ], + "outputs": [ + { + "name": "proxyAddress_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "ProxyDeployed", + "inputs": [ + { + "name": "deployer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "proxyAddress", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "vaultProxy", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + } +] diff --git a/packages/abis/abis/ISingleAssetRedemptionQueueFactory.sol b/packages/abis/abis/ISingleAssetRedemptionQueueFactory.sol new file mode 100644 index 00000000..63b1ec40 --- /dev/null +++ b/packages/abis/abis/ISingleAssetRedemptionQueueFactory.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.0 <0.9.0; + +interface ISingleAssetRedemptionQueueFactory { + event ProxyDeployed(address indexed deployer, address indexed proxyAddress, address indexed vaultProxy); + + function deployProxy( + address _vaultProxy, + address _redemptionAssetAddress, + uint256 _bypassableSharesThreshold, + address[] memory _managers + ) external returns (address proxyAddress_); +} diff --git a/packages/abis/abis/ISingleAssetRedemptionQueueLib.abi.json b/packages/abis/abis/ISingleAssetRedemptionQueueLib.abi.json new file mode 100644 index 00000000..4725e42f --- /dev/null +++ b/packages/abis/abis/ISingleAssetRedemptionQueueLib.abi.json @@ -0,0 +1,477 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_addressListRegistry", + "type": "address", + "internalType": "address" + }, + { + "name": "_gsnTrustedForwardersAddressListId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_globalConfigProxy", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "addManagers", + "inputs": [ + { + "name": "_managers", + "type": "address[]", + "internalType": "address[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getBypassableSharesThreshold", + "inputs": [], + "outputs": [ + { + "name": "sharesAmount_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getNextNewId", + "inputs": [], + "outputs": [ + { + "name": "id_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getNextQueuedId", + "inputs": [], + "outputs": [ + { + "name": "id_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRedemptionAsset", + "inputs": [], + "outputs": [ + { + "name": "asset_", + "type": "address", + "internalType": "contract IERC20" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getSharesForRequest", + "inputs": [ + { + "name": "_id", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "sharesAmount_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getUserForRequest", + "inputs": [ + { + "name": "_id", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "user_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getVaultProxy", + "inputs": [], + "outputs": [ + { + "name": "vaultProxy_", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "init", + "inputs": [ + { + "name": "_vaultProxy", + "type": "address", + "internalType": "address" + }, + { + "name": "_redemptionAsset", + "type": "address", + "internalType": "contract IERC20" + }, + { + "name": "_bypassableSharesThreshold", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_managers", + "type": "address[]", + "internalType": "address[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isManager", + "inputs": [ + { + "name": "_user", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "isManager_", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "queueIsShutdown", + "inputs": [], + "outputs": [ + { + "name": "isShutdown_", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "redeemFromQueue", + "inputs": [ + { + "name": "_endId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "_idsToBypass", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "removeManagers", + "inputs": [ + { + "name": "_managers", + "type": "address[]", + "internalType": "address[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "requestRedeem", + "inputs": [ + { + "name": "_sharesAmount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "id_", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setBypassableSharesThreshold", + "inputs": [ + { + "name": "_nextSharesThreshold", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRedemptionAsset", + "inputs": [ + { + "name": "_nextRedemptionAsset", + "type": "address", + "internalType": "contract IERC20" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "shutdown", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdrawRequest", + "inputs": [ + { + "name": "_id", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "BypassableSharesThresholdSet", + "inputs": [ + { + "name": "nextSharesAmount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "vaultProxy", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ManagerAdded", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ManagerRemoved", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Redeemed", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "redemptionAsset", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "redemptionAssetAmount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RedemptionAssetSet", + "inputs": [ + { + "name": "asset", + "type": "address", + "indexed": true, + "internalType": "contract IERC20" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RedemptionRequestAdded", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "sharesAmount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RequestBypassed", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RequestWithdrawn", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Shutdown", + "inputs": [], + "anonymous": false + }, + { + "type": "error", + "name": "AlreadyInitialized", + "inputs": [] + }, + { + "type": "error", + "name": "IsShutdown", + "inputs": [] + }, + { + "type": "error", + "name": "NotBypassable", + "inputs": [] + }, + { + "type": "error", + "name": "NotWithdrawable", + "inputs": [] + }, + { + "type": "error", + "name": "OutOfRange", + "inputs": [] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [] + }, + { + "type": "error", + "name": "UndefinedVaultProxy", + "inputs": [] + } +] diff --git a/packages/abis/abis/ISingleAssetRedemptionQueueLib.sol b/packages/abis/abis/ISingleAssetRedemptionQueueLib.sol new file mode 100644 index 00000000..a89ccec6 --- /dev/null +++ b/packages/abis/abis/ISingleAssetRedemptionQueueLib.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.6.0 <0.9.0; + +interface ISingleAssetRedemptionQueueLib { + error AlreadyInitialized(); + error IsShutdown(); + error NotBypassable(); + error NotWithdrawable(); + error OutOfRange(); + error Unauthorized(); + error UndefinedVaultProxy(); + + event BypassableSharesThresholdSet(uint256 nextSharesAmount); + event Initialized(address indexed vaultProxy); + event ManagerAdded(address indexed user); + event ManagerRemoved(address indexed user); + event Redeemed(uint256 indexed id, address indexed redemptionAsset, uint256 redemptionAssetAmount); + event RedemptionAssetSet(address indexed asset); + event RedemptionRequestAdded(uint256 indexed id, address indexed user, uint256 sharesAmount); + event RequestBypassed(uint256 indexed id); + event RequestWithdrawn(uint256 indexed id); + event Shutdown(); + + function addManagers(address[] memory _managers) external; + function getBypassableSharesThreshold() external view returns (uint256 sharesAmount_); + function getNextNewId() external view returns (uint256 id_); + function getNextQueuedId() external view returns (uint256 id_); + function getRedemptionAsset() external view returns (address asset_); + function getSharesForRequest(uint256 _id) external view returns (uint256 sharesAmount_); + function getUserForRequest(uint256 _id) external view returns (address user_); + function getVaultProxy() external view returns (address vaultProxy_); + function init( + address _vaultProxy, + address _redemptionAsset, + uint256 _bypassableSharesThreshold, + address[] memory _managers + ) external; + function isManager(address _user) external view returns (bool isManager_); + function queueIsShutdown() external view returns (bool isShutdown_); + function redeemFromQueue(uint256 _endId, uint256[] memory _idsToBypass) external; + function removeManagers(address[] memory _managers) external; + function requestRedeem(uint256 _sharesAmount) external returns (uint256 id_); + function setBypassableSharesThreshold(uint256 _nextSharesThreshold) external; + function setRedemptionAsset(address _nextRedemptionAsset) external; + function shutdown() external; + function withdrawRequest(uint256 _id) external; +} diff --git a/packages/abis/src/abis/ISingleAssetRedemptionQueueFactory.ts b/packages/abis/src/abis/ISingleAssetRedemptionQueueFactory.ts new file mode 100644 index 00000000..7f9001bf --- /dev/null +++ b/packages/abis/src/abis/ISingleAssetRedemptionQueueFactory.ts @@ -0,0 +1,72 @@ +export const ISingleAssetRedemptionQueueFactory = [ + { + type: "constructor", + inputs: [ + { + name: "_libAddress", + type: "address", + internalType: "address", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "deployProxy", + inputs: [ + { + name: "_vaultProxy", + type: "address", + internalType: "address", + }, + { + name: "_redemptionAssetAddress", + type: "address", + internalType: "address", + }, + { + name: "_bypassableSharesThreshold", + type: "uint256", + internalType: "uint256", + }, + { + name: "_managers", + type: "address[]", + internalType: "address[]", + }, + ], + outputs: [ + { + name: "proxyAddress_", + type: "address", + internalType: "address", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "event", + name: "ProxyDeployed", + inputs: [ + { + name: "deployer", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "proxyAddress", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "vaultProxy", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, +] as const; diff --git a/packages/abis/src/abis/ISingleAssetRedemptionQueueLib.ts b/packages/abis/src/abis/ISingleAssetRedemptionQueueLib.ts new file mode 100644 index 00000000..f224b3fa --- /dev/null +++ b/packages/abis/src/abis/ISingleAssetRedemptionQueueLib.ts @@ -0,0 +1,477 @@ +export const ISingleAssetRedemptionQueueLib = [ + { + type: "constructor", + inputs: [ + { + name: "_addressListRegistry", + type: "address", + internalType: "address", + }, + { + name: "_gsnTrustedForwardersAddressListId", + type: "uint256", + internalType: "uint256", + }, + { + name: "_globalConfigProxy", + type: "address", + internalType: "address", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "addManagers", + inputs: [ + { + name: "_managers", + type: "address[]", + internalType: "address[]", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "getBypassableSharesThreshold", + inputs: [], + outputs: [ + { + name: "sharesAmount_", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getNextNewId", + inputs: [], + outputs: [ + { + name: "id_", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getNextQueuedId", + inputs: [], + outputs: [ + { + name: "id_", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getRedemptionAsset", + inputs: [], + outputs: [ + { + name: "asset_", + type: "address", + internalType: "contract IERC20", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getSharesForRequest", + inputs: [ + { + name: "_id", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "sharesAmount_", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getUserForRequest", + inputs: [ + { + name: "_id", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "user_", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "getVaultProxy", + inputs: [], + outputs: [ + { + name: "vaultProxy_", + type: "address", + internalType: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "init", + inputs: [ + { + name: "_vaultProxy", + type: "address", + internalType: "address", + }, + { + name: "_redemptionAsset", + type: "address", + internalType: "contract IERC20", + }, + { + name: "_bypassableSharesThreshold", + type: "uint256", + internalType: "uint256", + }, + { + name: "_managers", + type: "address[]", + internalType: "address[]", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "isManager", + inputs: [ + { + name: "_user", + type: "address", + internalType: "address", + }, + ], + outputs: [ + { + name: "isManager_", + type: "bool", + internalType: "bool", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "queueIsShutdown", + inputs: [], + outputs: [ + { + name: "isShutdown_", + type: "bool", + internalType: "bool", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "redeemFromQueue", + inputs: [ + { + name: "_endId", + type: "uint256", + internalType: "uint256", + }, + { + name: "_idsToBypass", + type: "uint256[]", + internalType: "uint256[]", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "removeManagers", + inputs: [ + { + name: "_managers", + type: "address[]", + internalType: "address[]", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "requestRedeem", + inputs: [ + { + name: "_sharesAmount", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [ + { + name: "id_", + type: "uint256", + internalType: "uint256", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "setBypassableSharesThreshold", + inputs: [ + { + name: "_nextSharesThreshold", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "setRedemptionAsset", + inputs: [ + { + name: "_nextRedemptionAsset", + type: "address", + internalType: "contract IERC20", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "shutdown", + inputs: [], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + name: "withdrawRequest", + inputs: [ + { + name: "_id", + type: "uint256", + internalType: "uint256", + }, + ], + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "event", + name: "BypassableSharesThresholdSet", + inputs: [ + { + name: "nextSharesAmount", + type: "uint256", + indexed: false, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "Initialized", + inputs: [ + { + name: "vaultProxy", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "ManagerAdded", + inputs: [ + { + name: "user", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "ManagerRemoved", + inputs: [ + { + name: "user", + type: "address", + indexed: true, + internalType: "address", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "Redeemed", + inputs: [ + { + name: "id", + type: "uint256", + indexed: true, + internalType: "uint256", + }, + { + name: "redemptionAsset", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "redemptionAssetAmount", + type: "uint256", + indexed: false, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "RedemptionAssetSet", + inputs: [ + { + name: "asset", + type: "address", + indexed: true, + internalType: "contract IERC20", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "RedemptionRequestAdded", + inputs: [ + { + name: "id", + type: "uint256", + indexed: true, + internalType: "uint256", + }, + { + name: "user", + type: "address", + indexed: true, + internalType: "address", + }, + { + name: "sharesAmount", + type: "uint256", + indexed: false, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "RequestBypassed", + inputs: [ + { + name: "id", + type: "uint256", + indexed: true, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "RequestWithdrawn", + inputs: [ + { + name: "id", + type: "uint256", + indexed: true, + internalType: "uint256", + }, + ], + anonymous: false, + }, + { + type: "event", + name: "Shutdown", + inputs: [], + anonymous: false, + }, + { + type: "error", + name: "AlreadyInitialized", + inputs: [], + }, + { + type: "error", + name: "IsShutdown", + inputs: [], + }, + { + type: "error", + name: "NotBypassable", + inputs: [], + }, + { + type: "error", + name: "NotWithdrawable", + inputs: [], + }, + { + type: "error", + name: "OutOfRange", + inputs: [], + }, + { + type: "error", + name: "Unauthorized", + inputs: [], + }, + { + type: "error", + name: "UndefinedVaultProxy", + inputs: [], + }, +] as const; diff --git a/packages/abis/src/index.ts b/packages/abis/src/index.ts index 5d96a1e5..178a5f2b 100644 --- a/packages/abis/src/index.ts +++ b/packages/abis/src/index.ts @@ -110,6 +110,8 @@ export { IRevertingPriceFeed } from "./abis/IRevertingPriceFeed.js"; export { ISharePriceThrottledMultiCallAccount } from "./abis/ISharePriceThrottledMultiCallAccount.js"; export { ISharesSplitterFactory } from "./abis/ISharesSplitterFactory.js"; export { ISharesSplitterLib } from "./abis/ISharesSplitterLib.js"; +export { ISingleAssetRedemptionQueueFactory } from "./abis/ISingleAssetRedemptionQueueFactory.js"; +export { ISingleAssetRedemptionQueueLib } from "./abis/ISingleAssetRedemptionQueueLib.js"; export { ISolvV2BondBuyerPositionLib } from "./abis/ISolvV2BondBuyerPositionLib.js"; export { ISolvV2BondBuyerPositionParser } from "./abis/ISolvV2BondBuyerPositionParser.js"; export { ISolvV2BondIssuerPositionLib } from "./abis/ISolvV2BondIssuerPositionLib.js"; diff --git a/packages/sdk/src/Tools.ts b/packages/sdk/src/Tools.ts index b24ee77c..20100df6 100644 --- a/packages/sdk/src/Tools.ts +++ b/packages/sdk/src/Tools.ts @@ -1,3 +1,4 @@ export * as GatedRedemptionQueueSharesWrapper from "./Tools/GatedRedemptionQueueSharesWrapper.js"; export * as SharesSplitter from "./Tools/SharesSplitter.js"; +export * as SingleAssetRedemptionQueue from "./Tools/SingleAssetRedemptionQueue.js"; export * as UnpermissionedActionsWrapper from "./Tools/UnpermissionedActionsWrapper.js"; diff --git a/packages/sdk/src/Tools/SingleAssetRedemptionQueue.ts b/packages/sdk/src/Tools/SingleAssetRedemptionQueue.ts new file mode 100644 index 00000000..1b8b9a35 --- /dev/null +++ b/packages/sdk/src/Tools/SingleAssetRedemptionQueue.ts @@ -0,0 +1,256 @@ +import * as Abis from "@enzymefinance/abis"; +import { Address, PublicClient } from "viem"; +import { readContract } from "viem/actions"; +import { Viem } from "../Utils.js"; + +//-------------------------------------------------------------------------------------------- +// FACTORY +//-------------------------------------------------------------------------------------------- + +export function deployProxy(args: { + redemptionQueueFactory: Address; + vaultProxy: Address; + redemptionAsset: Address; + bypassableSharesThreshold: bigint; + managers: ReadonlyArray
; +}) { + return new Viem.PopulatedTransaction({ + abi: Abis.ISingleAssetRedemptionQueueFactory, + functionName: "deployProxy", + address: args.redemptionQueueFactory, + args: [args.vaultProxy, args.redemptionAsset, args.bypassableSharesThreshold, args.managers], + }); +} + +//-------------------------------------------------------------------------------------------- +// SHARE HOLDER TRANSACTIONS +//-------------------------------------------------------------------------------------------- + +export function requestRedeem(args: { + redemptionQueue: Address; + sharesAmount: bigint; +}) { + return new Viem.PopulatedTransaction({ + abi: Abis.ISingleAssetRedemptionQueueLib, + functionName: "requestRedeem", + address: args.redemptionQueue, + args: [args.sharesAmount], + }); +} + +export function withdrawRequest(args: { + redemptionQueue: Address; + requestId: bigint; +}) { + return new Viem.PopulatedTransaction({ + abi: Abis.ISingleAssetRedemptionQueueLib, + functionName: "withdrawRequest", + address: args.redemptionQueue, + args: [args.requestId], + }); +} + +//-------------------------------------------------------------------------------------------- +// MANAGER TRANSACTIONS +//-------------------------------------------------------------------------------------------- + +export function redeemFromQueue(args: { + redemptionQueue: Address; + endId: bigint; + idsToBypass: ReadonlyArray