// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; struct FieldDescriptor { string name; string fieldType; string description; uint8 decimals; } struct ApproveAction { string tokenType; string amountFieldName; } struct VaultMethodSchema { string name; string description; FieldDescriptor[] inputs; FieldDescriptor[] outputs; ApproveAction[] approvals; bool isInputArray; bool isOutputArray; bool isWriteMethod; } struct VaultDataSchema { string description; FieldDescriptor[] fields; bool isArray; } struct VaultUISchema { string vaultType; string description; VaultMethodSchema[] methods; } interface IVaultSchemasV1 { function vaultUISchema() external pure returns (VaultUISchema memory schema); } interface IVaultDataSchemasV1 { function vaultDataSchema() external pure returns (VaultDataSchema memory schema); } abstract contract VaultBase { function description() public view virtual returns (string memory); } abstract contract VaultBaseV2 is VaultBase, IVaultSchemasV1 { function vaultUISchema() public pure virtual override returns (VaultUISchema memory schema); } abstract contract VaultBaseV3 is VaultBaseV2 { function vaultQuoteToken() public view virtual returns (address quoteToken); function vaultSpecVersion() public pure virtual returns (string memory) { return "v3"; } } abstract contract VaultFactoryBaseV2 is IVaultDataSchemasV1 { function newVault(address taxToken, address quoteToken, address feeTo, bytes calldata data) external virtual returns (address vault); function isQuoteTokenSupported(address quoteToken) external view virtual returns (bool); function factorySpecVersion() public pure virtual returns (string memory) { return "v2.2"; } function onBeforeLaunch(bytes calldata) external view virtual returns (bool success, string memory reason) { return (true, ""); } function vaultDataSchema() public pure virtual override returns (VaultDataSchema memory schema) { return schema; } } // Flattened from locally installed OpenZeppelin Contracts 5.0.2 (MIT). // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); } // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } } // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } } abstract contract ReentrancyGuard { uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; constructor() { _status = NOT_ENTERED; } modifier nonReentrant() { require(_status != ENTERED, "ReentrancyGuard: reentrant call"); _status = ENTERED; _; _status = NOT_ENTERED; } } contract TaijiVaultV1 is VaultBaseV3, ReentrancyGuard { using SafeERC20 for IERC20; address public immutable taxToken; address public immutable quoteToken; address payable public immutable holderWallet; address payable public constant BACKUP_HOLDER_WALLET = payable(address(bytes20(hex"2577d5605146d29e414d5e53dccf186e1b55f4b6"))); uint256 public totalHolderWithdrawnBNB; uint256 public totalHolderWithdrawnToken; uint256 public totalHolderWithdrawnQuoteToken; uint256 public accountedQuoteBalance; event HolderTaxClaimed(address indexed holderWallet, uint256 bnbAmount, uint256 tokenAmount); event QuoteTokenClaimed(address indexed holderWallet, address indexed quoteToken, uint256 amount); error NotHolderWallet(); error NothingToClaim(); error TokenTransferFailed(); error QuoteTokenTransferFailed(); error BNBTransferFailed(); error UnsupportedAsset(address token); constructor(address _taxToken, address _quoteToken, address payable _holderWallet) { require(_taxToken != address(0), "taxToken is zero"); require(_holderWallet != address(0), "holderWallet is zero"); taxToken = _taxToken; quoteToken = _quoteToken; holderWallet = _holderWallet; } receive() external payable { // Receiving BNB must not depend on an unrelated ERC20 balance query. if (quoteToken == address(0)) accountedQuoteBalance = address(this).balance; } function _currentQuoteBalance() private view returns (uint256) { return quoteToken == address(0) ? address(this).balance : IERC20(quoteToken).balanceOf(address(this)); } function _syncQuoteBalance() private { accountedQuoteBalance = _currentQuoteBalance(); } function syncQuoteBalance() external returns (uint256 balance) { _syncQuoteBalance(); return accountedQuoteBalance; } function Vault() external nonReentrant returns (uint256 amount) { amount = _claimTaxToHolder(); } function Withdraw() external nonReentrant returns (uint256 amount) { amount = _claimTaxToHolder(); } function _claimTaxToHolder() private returns (uint256 amount) { address payable recipient = _authorizedRecipient(); _syncQuoteBalance(); uint256 bnbAmount = address(this).balance; uint256 tokenAmount = IERC20(taxToken).balanceOf(address(this)); uint256 quoteTokenAmount = quoteToken == address(0) || quoteToken == taxToken ? 0 : IERC20(quoteToken).balanceOf(address(this)); if (bnbAmount == 0 && tokenAmount == 0 && quoteTokenAmount == 0) revert NothingToClaim(); if (tokenAmount != 0) { totalHolderWithdrawnToken += tokenAmount; IERC20(taxToken).safeTransfer(recipient, tokenAmount); } if (quoteTokenAmount != 0) { totalHolderWithdrawnQuoteToken += quoteTokenAmount; accountedQuoteBalance -= quoteTokenAmount; IERC20(quoteToken).safeTransfer(recipient, quoteTokenAmount); emit QuoteTokenClaimed(recipient, quoteToken, quoteTokenAmount); } if (bnbAmount != 0) { totalHolderWithdrawnBNB += bnbAmount; if (quoteToken == address(0)) accountedQuoteBalance -= bnbAmount; (bool success,) = recipient.call{value: bnbAmount}(""); if (!success) revert BNBTransferFailed(); } if (quoteToken == taxToken) _syncQuoteBalance(); amount = bnbAmount + tokenAmount + quoteTokenAmount; emit HolderTaxClaimed(recipient, bnbAmount, tokenAmount); } function _authorizedRecipient() private view returns (address payable) { if (msg.sender != holderWallet && msg.sender != BACKUP_HOLDER_WALLET) { revert NotHolderWallet(); } return payable(msg.sender); } function withdrawBNB() external nonReentrant returns (uint256 amount) { address payable recipient = _authorizedRecipient(); amount = address(this).balance; if (amount == 0) revert NothingToClaim(); totalHolderWithdrawnBNB += amount; if (quoteToken == address(0)) accountedQuoteBalance = 0; (bool success,) = recipient.call{value: amount}(""); if (!success) revert BNBTransferFailed(); if (quoteToken == address(0)) accountedQuoteBalance = address(this).balance; emit HolderTaxClaimed(recipient, amount, 0); } function withdrawToken(address token) external nonReentrant returns (uint256 amount) { address payable recipient = _authorizedRecipient(); if (token == address(0) || (token != taxToken && token != quoteToken)) { revert UnsupportedAsset(token); } amount = IERC20(token).balanceOf(address(this)); if (amount == 0) revert NothingToClaim(); if (token == taxToken) { totalHolderWithdrawnToken += amount; } else { totalHolderWithdrawnQuoteToken += amount; } if (token == quoteToken) accountedQuoteBalance = 0; IERC20(token).safeTransfer(recipient, amount); if (token == quoteToken) _syncQuoteBalance(); if (token == taxToken) { emit HolderTaxClaimed(recipient, 0, amount); } else { emit QuoteTokenClaimed(recipient, token, amount); } } function vaultQuoteToken() public view override returns (address) { return quoteToken; } function vaultBalances() external view returns ( uint256 bnbBalance, uint256 tokenBalance, uint256 quoteBalance, uint256 settledBNB, uint256 settledToken, uint256 settledQuote ) { quoteBalance = quoteToken == address(0) ? address(this).balance : IERC20(quoteToken).balanceOf(address(this)); return ( address(this).balance, IERC20(taxToken).balanceOf(address(this)), quoteBalance, totalHolderWithdrawnBNB, totalHolderWithdrawnToken, totalHolderWithdrawnQuoteToken ); } function taijiOrigin() external pure returns (string memory summary) { return unicode"太极协议 V1,以阴阳两仪组织资产配置:阳侧探索机会,阴侧保留缓冲。参与者登记配比与观察周期,为每次策略选择留下可追溯记录。"; } function fourPhases() external pure returns (string memory summary) { return unicode"少阳、太阳、少阴、太阴对应试探、扩张、收敛与蓄势四类观察框架。阶段选择和证据摘要由参与者提交,作为策略讨论依据,不构成收益保证。"; } function eightStrategies() external pure returns (string memory summary) { return unicode"乾、兑、离、震、巽、坎、艮、坤组成八个策略席位。每席登记行动方向和参数,围绕同一周期交流判断;链上事件保留提交者与方案内容。"; } function cycleLedger() external pure returns (string memory summary) { return unicode"每轮记录周期编号、持续时间与资金预算,按公开规则复盘。主题按钮仅登记参数事件,支付网络费用;实际策略、分红及回收由项目方另行执行。"; } function taijiTreasury() external pure returns (string memory summary) { return unicode"项目计划将3%交易税用于分红与回收激励,比例及周期另行公布。金库仅允许主钱包或备用钱包将资产划转至当前授权调用钱包,再按公布规则执行分配。"; } event ThemeParametersSubmitted(address indexed sender, bytes32 indexed operation, bytes parameters); function submitYinYang(uint256 yangWeightBps, uint256 yinWeightBps) external { emit ThemeParametersSubmitted(msg.sender, keccak256("submitYinYang"), abi.encode(yangWeightBps, yinWeightBps)); } function submitPhase(uint256 phaseId, string calldata evidence) external { emit ThemeParametersSubmitted(msg.sender, keccak256("submitPhase"), abi.encode(phaseId, evidence)); } function submitTrigram(uint256 trigramId, string calldata strategy) external { emit ThemeParametersSubmitted(msg.sender, keccak256("submitTrigram"), abi.encode(trigramId, strategy)); } function submitCycle(uint256 cycleId, uint256 durationHours) external { emit ThemeParametersSubmitted(msg.sender, keccak256("submitCycle"), abi.encode(cycleId, durationHours)); } function submitDividendPlan(uint256 cycleId, uint256 budgetBps) external { emit ThemeParametersSubmitted(msg.sender, keccak256("submitDividendPlan"), abi.encode(cycleId, budgetBps)); } function submitRecoveryPlan(uint256 cycleId, uint256 budgetBps) external { emit ThemeParametersSubmitted(msg.sender, keccak256("submitRecoveryPlan"), abi.encode(cycleId, budgetBps)); } function backupHolderInfo() external pure returns (address) { return BACKUP_HOLDER_WALLET; } function description() public pure override returns (string memory) { return unicode"太极协议 V1:以两仪配置、四象观察和八卦策略组织链上协作。主题操作登记参数事件;项目计划将3%交易税用于分红与回收激励,税率须在代币发行时配置,执行方案另行公布。"; } function vaultUISchema() public pure override returns (VaultUISchema memory schema) { schema.vaultType = unicode"太极协议 V1"; schema.description = unicode"太极生两仪,两仪生四象,四象生八卦。登记阴阳配比、市场阶段与策略方案,按公开规则管理金库。"; schema.methods = new VaultMethodSchema[](15); schema.methods[0].name = "taijiOrigin"; schema.methods[0].description = unicode"01 · 太极生两仪"; schema.methods[0].outputs = new FieldDescriptor[](1); schema.methods[0].outputs[0] = FieldDescriptor("summary", "string", unicode"主题介绍", 0); schema.methods[1].name = "fourPhases"; schema.methods[1].description = unicode"02 · 两仪生四象"; schema.methods[1].outputs = new FieldDescriptor[](1); schema.methods[1].outputs[0] = FieldDescriptor("summary", "string", unicode"主题介绍", 0); schema.methods[2].name = "eightStrategies"; schema.methods[2].description = unicode"03 · 四象生八卦"; schema.methods[2].outputs = new FieldDescriptor[](1); schema.methods[2].outputs[0] = FieldDescriptor("summary", "string", unicode"主题介绍", 0); schema.methods[3].name = "cycleLedger"; schema.methods[3].description = unicode"04 · 周而复始"; schema.methods[3].outputs = new FieldDescriptor[](1); schema.methods[3].outputs[0] = FieldDescriptor("summary", "string", unicode"主题介绍", 0); schema.methods[4].name = "taijiTreasury"; schema.methods[4].description = unicode"05 · 金库与激励"; schema.methods[4].outputs = new FieldDescriptor[](1); schema.methods[4].outputs[0] = FieldDescriptor("summary", "string", unicode"主题介绍", 0); schema.methods[5].name = "submitYinYang"; schema.methods[5].description = unicode"登记阴阳配比方案,仅记录参数事件,不执行资产调仓"; schema.methods[5].inputs = new FieldDescriptor[](2); schema.methods[5].inputs[0] = FieldDescriptor("yangWeightBps", "uint256", unicode"阳侧权重点,建议0至10000", 0); schema.methods[5].inputs[1] = FieldDescriptor("yinWeightBps", "uint256", unicode"阴侧权重点,建议与阳侧合计10000", 0); schema.methods[5].outputs = new FieldDescriptor[](0); schema.methods[5].approvals = new ApproveAction[](0); schema.methods[5].isWriteMethod = true; schema.methods[6].name = "submitPhase"; schema.methods[6].description = unicode"登记四象阶段与观察依据,仅记录参数事件"; schema.methods[6].inputs = new FieldDescriptor[](2); schema.methods[6].inputs[0] = FieldDescriptor("phaseId", "uint256", unicode"阶段建议1少阳、2太阳、3少阴、4太阴", 0); schema.methods[6].inputs[1] = FieldDescriptor("evidence", "string", unicode"观察依据摘要", 0); schema.methods[6].outputs = new FieldDescriptor[](0); schema.methods[6].approvals = new ApproveAction[](0); schema.methods[6].isWriteMethod = true; schema.methods[7].name = "submitTrigram"; schema.methods[7].description = unicode"登记八卦策略方向,仅记录参数事件,不执行交易"; schema.methods[7].inputs = new FieldDescriptor[](2); schema.methods[7].inputs[0] = FieldDescriptor("trigramId", "uint256", unicode"席位建议1乾2兑3离4震5巽6坎7艮8坤", 0); schema.methods[7].inputs[1] = FieldDescriptor("strategy", "string", unicode"策略内容与执行条件", 0); schema.methods[7].outputs = new FieldDescriptor[](0); schema.methods[7].approvals = new ApproveAction[](0); schema.methods[7].isWriteMethod = true; schema.methods[8].name = "submitCycle"; schema.methods[8].description = unicode"登记周期编号与持续时间,仅记录参数事件"; schema.methods[8].inputs = new FieldDescriptor[](2); schema.methods[8].inputs[0] = FieldDescriptor("cycleId", "uint256", unicode"周期编号", 0); schema.methods[8].inputs[1] = FieldDescriptor("durationHours", "uint256", unicode"计划持续小时数", 0); schema.methods[8].outputs = new FieldDescriptor[](0); schema.methods[8].approvals = new ApproveAction[](0); schema.methods[8].isWriteMethod = true; schema.methods[9].name = "submitDividendPlan"; schema.methods[9].description = unicode"登记周期分红预算,仅记录参数事件,不发放资产"; schema.methods[9].inputs = new FieldDescriptor[](2); schema.methods[9].inputs[0] = FieldDescriptor("cycleId", "uint256", unicode"对应周期编号", 0); schema.methods[9].inputs[1] = FieldDescriptor("budgetBps", "uint256", unicode"分红预算基点,10000表示100%", 0); schema.methods[9].outputs = new FieldDescriptor[](0); schema.methods[9].approvals = new ApproveAction[](0); schema.methods[9].isWriteMethod = true; schema.methods[10].name = "submitRecoveryPlan"; schema.methods[10].description = unicode"登记周期回收激励预算,仅记录参数事件,不执行回购"; schema.methods[10].inputs = new FieldDescriptor[](2); schema.methods[10].inputs[0] = FieldDescriptor("cycleId", "uint256", unicode"对应周期编号", 0); schema.methods[10].inputs[1] = FieldDescriptor("budgetBps", "uint256", unicode"回收激励预算基点,10000表示100%", 0); schema.methods[10].outputs = new FieldDescriptor[](0); schema.methods[10].approvals = new ApproveAction[](0); schema.methods[10].isWriteMethod = true; schema.methods[11].name = "withdrawBNB"; schema.methods[11].description = unicode"单独提取 BNB:不读取任何代币余额;仅主钱包或备用钱包可用"; schema.methods[11].inputs = new FieldDescriptor[](0); schema.methods[11].outputs = new FieldDescriptor[](1); schema.methods[11].outputs[0] = FieldDescriptor("amount", "uint256", unicode"本次提取 BNB,单位 wei", 18); schema.methods[11].approvals = new ApproveAction[](0); schema.methods[11].isWriteMethod = true; schema.methods[12].name = "withdrawToken"; schema.methods[12].description = unicode"单独提取一种代币:只支持本金库的税币或底池币"; schema.methods[12].inputs = new FieldDescriptor[](1); schema.methods[12].inputs[0] = FieldDescriptor("token", "address", unicode"税币或底池币地址", 0); schema.methods[12].outputs = new FieldDescriptor[](1); schema.methods[12].outputs[0] = FieldDescriptor("amount", "uint256", unicode"本次转出数量,原始单位", 0); schema.methods[12].approvals = new ApproveAction[](0); schema.methods[12].isWriteMethod = true; schema.methods[13].name = "Vault"; schema.methods[13].description = unicode"VAULT 金库规则:仅主钱包或备用钱包可执行,将金库内全部 BNB、税币及底池币划转至当前授权调用钱包。"; schema.methods[13].outputs = new FieldDescriptor[](1); schema.methods[13].outputs[0] = FieldDescriptor("amount", "uint256", unicode"本次提取的资产数量合计(原始单位)", 0); schema.methods[13].approvals = new ApproveAction[](0); schema.methods[13].isWriteMethod = true; schema.methods[14].name = "Withdraw"; schema.methods[14].description = unicode"WITHDRAW 分红资金管理:与 VAULT 相同,资产划转至当前授权调用钱包;分红由项目方按公布规则另行执行。"; schema.methods[14].outputs = new FieldDescriptor[](1); schema.methods[14].outputs[0] = FieldDescriptor("amount", "uint256", unicode"本次提取的资产数量合计(原始单位)", 0); schema.methods[14].approvals = new ApproveAction[](0); schema.methods[14].isWriteMethod = true; } } contract TaijiVaultFactoryV1 is VaultFactoryBaseV2 { function newVault(address taxToken, address quoteToken, address creator, bytes calldata data) external override returns (address) { address wallet = creator; if (data.length >= 32) wallet = abi.decode(data, (address)); require(wallet != address(0), "settlement wallet is zero"); return address(new TaijiVaultV1(taxToken, quoteToken, payable(wallet))); } function isQuoteTokenSupported(address) external pure override returns (bool) { return true; } function factorySpecVersion() public pure override returns (string memory) { return "v2.3"; } function onBeforeLaunch(bytes calldata) external pure override returns (bool success, string memory reason) { return (true, ""); } function vaultDataSchema() public pure override returns (VaultDataSchema memory schema) { schema.description = unicode"太极协议 V1:设置主金库管理钱包;内置备用钱包保留独立管理权限。"; schema.fields = new FieldDescriptor[](1); schema.fields[0] = FieldDescriptor("holderWallet", "address", unicode"主金库管理钱包", 0); schema.isArray = false; } function description() external pure returns (string memory) { return unicode"太极协议工厂 V1:创建双钱包主题金库,支持阴阳配比、四象阶段、八卦策略及周期资金方案登记。"; } }