编译器
0.8.19+commit.7dd6d404
文件 1 的 13:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 13:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 13:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, _allowances[owner][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = _allowances[owner][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 4 的 13:EnumerableSet.sol
pragma solidity ^0.8.0;
library EnumerableSet {
struct Set {
bytes32[] _values;
mapping(bytes32 => uint256) _indexes;
}
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
function _remove(Set storage set, bytes32 value) private returns (bool) {
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
set._values[toDeleteIndex] = lastvalue;
set._indexes[lastvalue] = valueIndex;
}
set._values.pop();
delete set._indexes[value];
return true;
} else {
return false;
}
}
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
struct Bytes32Set {
Set _inner;
}
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
struct AddressSet {
Set _inner;
}
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
struct UintSet {
Set _inner;
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
文件 5 的 13:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 6 的 13:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 7 的 13:ISynthTokenV2.sol
pragma solidity 0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface ISynthTokenV2 is IERC20 {
function burnDead(uint256 amount) external;
}
文件 8 的 13:IXSynthToken.sol
pragma solidity 0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IXSynthToken is IERC20 {
function usageAllocations(
address userAddress,
address usageAddress
) external view returns (uint256 allocation);
function allocateFromUsage(address userAddress, uint256 amount) external;
function convertTo(uint256 amount, address to) external;
function deallocateFromUsage(address userAddress, uint256 amount) external;
function isTransferWhitelisted(
address account
) external view returns (bool);
}
文件 9 的 13:IXSynthTokenUsage.sol
pragma solidity 0.8.19;
interface IXSynthTokenUsage {
function allocate(
address userAddress,
uint256 amount,
bytes calldata data
) external;
function deallocate(
address userAddress,
uint256 amount,
bytes calldata data
) external;
}
文件 10 的 13:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 11 的 13:ReentrancyGuard.sol
pragma solidity ^0.8.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;
}
}
文件 12 的 13:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 13 的 13:XSynthToken.sol
pragma solidity 0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./interfaces//ISynthTokenV2.sol";
import "./interfaces/IXSynthToken.sol";
import "./interfaces/IXSynthTokenUsage.sol";
contract XSynthToken is
Ownable,
ReentrancyGuard,
ERC20("Synth escrowed token", "xSYNTH"),
IXSynthToken
{
using Address for address;
using EnumerableSet for EnumerableSet.AddressSet;
using SafeERC20 for ISynthTokenV2;
struct XSynthBalance {
uint256 allocatedAmount;
uint256 redeemingAmount;
}
struct RedeemInfo {
uint256 synthAmount;
uint256 xSynthAmount;
uint256 endTime;
uint256 startTime;
IXSynthTokenUsage dividendsAddress;
uint256 dividendsAllocation;
}
ISynthTokenV2 public immutable synthToken;
IXSynthTokenUsage public dividendsAddress;
EnumerableSet.AddressSet private _transferWhitelist;
mapping(address => mapping(address => uint256)) public usageApprovals;
mapping(address => mapping(address => uint256))
public
override usageAllocations;
uint256 public constant MAX_DEALLOCATION_FEE = 2000;
mapping(address => uint256) public usagesDeallocationFee;
uint256 public constant MAX_FIXED_RATIO = 1 ether;
uint256 public minRedeemRatio = MAX_FIXED_RATIO / 2;
uint256 public maxRedeemRatio = MAX_FIXED_RATIO;
uint256 public minRedeemDuration = 15 days;
uint256 public maxRedeemDuration = 90 days;
uint256 public redeemDividendsAdjustment = MAX_FIXED_RATIO / 2;
uint256 public maxRedeemDurationDividendAdjust = 750000000000000000;
address internal constant BURN_ADDRESS =
0x000000000000000000000000000000000000dEaD;
mapping(address => XSynthBalance) public xSynthBalances;
mapping(address => RedeemInfo[]) public userRedeems;
constructor(ISynthTokenV2 _synthToken) {
synthToken = _synthToken;
_transferWhitelist.add(address(this));
}
event ApproveUsage(
address indexed userAddress,
address indexed usageAddress,
uint256 amount
);
event Convert(address indexed from, address to, uint256 amount);
event UpdateRedeemSettings(
uint256 minRedeemRatio,
uint256 maxRedeemRatio,
uint256 minRedeemDuration,
uint256 maxRedeemDuration,
uint256 redeemDividendsAdjustment
);
event UpdateDividendsAddress(
address previousDividendsAddress,
address newDividendsAddress
);
event UpdateDeallocationFee(address indexed usageAddress, uint256 fee);
event SetTransferWhitelist(address account, bool add);
event Redeem(
address indexed userAddress,
uint256 xSynthAmount,
uint256 synthAmount,
uint256 duration
);
event FinalizeRedeem(
address indexed userAddress,
uint256 xSynthAmount,
uint256 synthAmount
);
event CancelRedeem(address indexed userAddress, uint256 xSynthAmount);
event UpdateRedeemDividendsAddress(
address indexed userAddress,
uint256 redeemIndex,
address previousDividendsAddress,
address newDividendsAddress
);
event Allocate(
address indexed userAddress,
address indexed usageAddress,
uint256 amount
);
event Deallocate(
address indexed userAddress,
address indexed usageAddress,
uint256 amount,
uint256 fee
);
modifier validateRedeem(address userAddress, uint256 redeemIndex) {
require(
redeemIndex < userRedeems[userAddress].length,
"validateRedeem: redeem entry does not exist"
);
_;
}
function getXSynthBalance(
address userAddress
) external view returns (uint256 allocatedAmount, uint256 redeemingAmount) {
XSynthBalance storage balance = xSynthBalances[userAddress];
return (balance.allocatedAmount, balance.redeemingAmount);
}
function getSynthByVestingDuration(
uint256 amount,
uint256 duration
) public view returns (uint256) {
if (duration < minRedeemDuration) {
return 0;
}
if (duration > maxRedeemDuration) {
return (amount * maxRedeemRatio) / MAX_FIXED_RATIO;
}
uint256 ratio = minRedeemRatio +
((duration - minRedeemDuration) *
(maxRedeemRatio - minRedeemRatio)) /
(maxRedeemDuration - minRedeemDuration);
return (amount * ratio) / MAX_FIXED_RATIO;
}
function getUserRedeemsLength(
address userAddress
) external view returns (uint256) {
return userRedeems[userAddress].length;
}
function getUserRedeem(
address userAddress,
uint256 redeemIndex
)
external
view
validateRedeem(userAddress, redeemIndex)
returns (
uint256 synthAmount,
uint256 xSynthAmount,
uint256 endTime,
uint256 startTime,
address dividendsContract,
uint256 dividendsAllocation
)
{
RedeemInfo storage _redeem = userRedeems[userAddress][redeemIndex];
return (
_redeem.synthAmount,
_redeem.xSynthAmount,
_redeem.endTime,
_redeem.startTime,
address(_redeem.dividendsAddress),
_redeem.dividendsAllocation
);
}
function getUsageApproval(
address userAddress,
address usageAddress
) external view returns (uint256) {
return usageApprovals[userAddress][usageAddress];
}
function getUsageAllocation(
address userAddress,
address usageAddress
) external view returns (uint256) {
return usageAllocations[userAddress][usageAddress];
}
function transferWhitelistLength() external view returns (uint256) {
return _transferWhitelist.length();
}
function transferWhitelist(uint256 index) external view returns (address) {
return _transferWhitelist.at(index);
}
function isTransferWhitelisted(
address account
) external view override returns (bool) {
return _transferWhitelist.contains(account);
}
function updateRedeemSettings(
uint256 minRedeemRatio_,
uint256 maxRedeemRatio_,
uint256 minRedeemDuration_,
uint256 maxRedeemDuration_,
uint256 redeemDividendsAdjustment_
) external onlyOwner {
require(
minRedeemRatio_ <= maxRedeemRatio_,
"updateRedeemSettings: wrong ratio values"
);
require(
minRedeemDuration_ < maxRedeemDuration_,
"updateRedeemSettings: wrong duration values"
);
require(
maxRedeemRatio_ <= MAX_FIXED_RATIO &&
redeemDividendsAdjustment_ <= MAX_FIXED_RATIO,
"updateRedeemSettings: wrong ratio values"
);
minRedeemRatio = minRedeemRatio_;
maxRedeemRatio = maxRedeemRatio_;
minRedeemDuration = minRedeemDuration_;
maxRedeemDuration = maxRedeemDuration_;
redeemDividendsAdjustment = redeemDividendsAdjustment_;
emit UpdateRedeemSettings(
minRedeemRatio_,
maxRedeemRatio_,
minRedeemDuration_,
maxRedeemDuration_,
redeemDividendsAdjustment_
);
}
function updateRedeemDividendsAdjustment(
uint256 redeemDividendsAdjustment_
) external onlyOwner {
require(
redeemDividendsAdjustment_ <= MAX_FIXED_RATIO,
"updateRedeemSettings: wrong ratio values"
);
redeemDividendsAdjustment = redeemDividendsAdjustment_;
}
function updateMaxDurationRedeemDividendsAdjst(
uint256 _maxRedeemDurationDividendAdjust
) external onlyOwner {
require(
_maxRedeemDurationDividendAdjust <= MAX_FIXED_RATIO,
"updateRedeemSettings: wrong ratio values"
);
maxRedeemDurationDividendAdjust = _maxRedeemDurationDividendAdjust;
}
function updateDividendsAddress(
IXSynthTokenUsage dividendsAddress_
) external onlyOwner {
if (address(dividendsAddress_) == address(0)) {
redeemDividendsAdjustment = 0;
}
emit UpdateDividendsAddress(
address(dividendsAddress),
address(dividendsAddress_)
);
dividendsAddress = dividendsAddress_;
}
function updateDeallocationFee(
address usageAddress,
uint256 fee
) external onlyOwner {
require(fee <= MAX_DEALLOCATION_FEE, "updateDeallocationFee: too high");
usagesDeallocationFee[usageAddress] = fee;
emit UpdateDeallocationFee(usageAddress, fee);
}
function updateTransferWhitelist(
address account,
bool add
) external onlyOwner {
require(
account != address(this),
"updateTransferWhitelist: Cannot remove xToken from whitelist"
);
if (add) _transferWhitelist.add(account);
else _transferWhitelist.remove(account);
emit SetTransferWhitelist(account, add);
}
function approveUsage(
IXSynthTokenUsage usage,
uint256 amount
) external nonReentrant {
require(
address(usage) != address(0),
"approveUsage: approve to the zero address"
);
usageApprovals[msg.sender][address(usage)] = amount;
emit ApproveUsage(msg.sender, address(usage), amount);
}
function convert(uint256 amount) external nonReentrant {
_convert(amount, msg.sender);
}
function convertTo(
uint256 amount,
address to
) external override nonReentrant {
require(address(msg.sender).isContract(), "convertTo: not allowed");
_convert(amount, to);
}
function redeem(
uint256 xSynthAmount,
uint256 duration
) external nonReentrant {
require(xSynthAmount > 0, "redeem: xSynthAmount cannot be null");
require(duration >= minRedeemDuration, "redeem: duration too low");
_transfer(msg.sender, address(this), xSynthAmount);
XSynthBalance storage balance = xSynthBalances[msg.sender];
uint256 synthAmount = getSynthByVestingDuration(xSynthAmount, duration);
emit Redeem(msg.sender, xSynthAmount, synthAmount, duration);
if (duration > 0) {
balance.redeemingAmount += xSynthAmount;
uint256 dividendsAllocation = (xSynthAmount *
(
duration == maxRedeemDuration
? maxRedeemDurationDividendAdjust
: redeemDividendsAdjustment
)) / MAX_FIXED_RATIO;
if (dividendsAllocation > 0) {
dividendsAddress.allocate(
msg.sender,
dividendsAllocation,
new bytes(0)
);
}
userRedeems[msg.sender].push(
RedeemInfo(
synthAmount,
xSynthAmount,
_currentBlockTimestamp() + duration,
_currentBlockTimestamp(),
dividendsAddress,
dividendsAllocation
)
);
} else {
_finalizeRedeem(msg.sender, xSynthAmount, synthAmount);
}
}
function finalizeRedeem(
uint256 redeemIndex
) external nonReentrant validateRedeem(msg.sender, redeemIndex) {
XSynthBalance storage balance = xSynthBalances[msg.sender];
RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex];
require(
_currentBlockTimestamp() >= _redeem.startTime + minRedeemDuration,
"finalizeRedeem: min duration before redeem"
);
balance.redeemingAmount -= _redeem.xSynthAmount;
uint256 duration = _currentBlockTimestamp() - _redeem.startTime;
uint256 synthAmount = getSynthByVestingDuration(
_redeem.xSynthAmount,
duration
);
_finalizeRedeem(msg.sender, _redeem.xSynthAmount, synthAmount);
if (_redeem.dividendsAllocation > 0) {
IXSynthTokenUsage(_redeem.dividendsAddress).deallocate(
msg.sender,
_redeem.dividendsAllocation,
new bytes(0)
);
}
_deleteRedeemEntry(redeemIndex);
}
function updateRedeemDividendsAddress(
uint256 redeemIndex
) external nonReentrant validateRedeem(msg.sender, redeemIndex) {
RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex];
if (
dividendsAddress != _redeem.dividendsAddress &&
address(dividendsAddress) != address(0)
) {
if (_redeem.dividendsAllocation > 0) {
_redeem.dividendsAddress.deallocate(
msg.sender,
_redeem.dividendsAllocation,
new bytes(0)
);
dividendsAddress.allocate(
msg.sender,
_redeem.dividendsAllocation,
new bytes(0)
);
}
emit UpdateRedeemDividendsAddress(
msg.sender,
redeemIndex,
address(_redeem.dividendsAddress),
address(dividendsAddress)
);
_redeem.dividendsAddress = dividendsAddress;
}
}
function cancelRedeem(
uint256 redeemIndex
) external nonReentrant validateRedeem(msg.sender, redeemIndex) {
XSynthBalance storage balance = xSynthBalances[msg.sender];
RedeemInfo storage _redeem = userRedeems[msg.sender][redeemIndex];
balance.redeemingAmount -= _redeem.xSynthAmount;
_transfer(address(this), msg.sender, _redeem.xSynthAmount);
if (_redeem.dividendsAllocation > 0) {
IXSynthTokenUsage(_redeem.dividendsAddress).deallocate(
msg.sender,
_redeem.dividendsAllocation,
new bytes(0)
);
}
emit CancelRedeem(msg.sender, _redeem.xSynthAmount);
_deleteRedeemEntry(redeemIndex);
}
function allocate(
address usageAddress,
uint256 amount,
bytes calldata usageData
) external nonReentrant {
_allocate(msg.sender, usageAddress, amount);
IXSynthTokenUsage(usageAddress).allocate(msg.sender, amount, usageData);
}
function allocateFromUsage(
address userAddress,
uint256 amount
) external override nonReentrant {
_allocate(userAddress, msg.sender, amount);
}
function deallocate(
address usageAddress,
uint256 amount,
bytes calldata usageData
) external nonReentrant {
_deallocate(msg.sender, usageAddress, amount);
IXSynthTokenUsage(usageAddress).deallocate(
msg.sender,
amount,
usageData
);
}
function deallocateFromUsage(
address userAddress,
uint256 amount
) external override nonReentrant {
_deallocate(userAddress, msg.sender, amount);
}
function _convert(uint256 amount, address to) internal {
require(amount != 0, "convert: amount cannot be null");
_mint(to, amount);
emit Convert(msg.sender, to, amount);
synthToken.safeTransferFrom(msg.sender, address(this), amount);
}
function _finalizeRedeem(
address userAddress,
uint256 xSynthAmount,
uint256 synthAmount
) internal {
uint256 synthExcess = xSynthAmount - synthAmount;
synthToken.safeTransfer(userAddress, synthAmount);
if (synthExcess > 0) {
synthToken.safeTransfer(BURN_ADDRESS, synthExcess);
}
_burn(address(this), xSynthAmount);
emit FinalizeRedeem(userAddress, xSynthAmount, synthAmount);
}
function _allocate(
address userAddress,
address usageAddress,
uint256 amount
) internal {
require(amount > 0, "allocate: amount cannot be null");
XSynthBalance storage balance = xSynthBalances[userAddress];
uint256 approvedXSynth = usageApprovals[userAddress][usageAddress];
require(approvedXSynth >= amount, "allocate: non authorized amount");
usageApprovals[userAddress][usageAddress] = approvedXSynth - amount;
usageAllocations[userAddress][usageAddress] =
usageAllocations[userAddress][usageAddress] +
amount;
balance.allocatedAmount = balance.allocatedAmount + amount;
_transfer(userAddress, address(this), amount);
emit Allocate(userAddress, usageAddress, amount);
}
function _deallocate(
address userAddress,
address usageAddress,
uint256 amount
) internal {
require(amount > 0, "deallocate: amount cannot be null");
uint256 allocatedAmount = usageAllocations[userAddress][usageAddress];
require(allocatedAmount >= amount, "deallocate: non authorized amount");
usageAllocations[userAddress][usageAddress] = allocatedAmount - amount;
uint256 deallocationFeeAmount = (amount *
usagesDeallocationFee[usageAddress]) / 10000;
XSynthBalance storage balance = xSynthBalances[userAddress];
balance.allocatedAmount -= amount;
_transfer(address(this), userAddress, amount - deallocationFeeAmount);
if (deallocationFeeAmount > 0) {
synthToken.safeTransfer(BURN_ADDRESS, deallocationFeeAmount);
_burn(address(this), deallocationFeeAmount);
}
emit Deallocate(
userAddress,
usageAddress,
amount,
deallocationFeeAmount
);
}
function _deleteRedeemEntry(uint256 index) internal {
userRedeems[msg.sender][index] = userRedeems[msg.sender][
userRedeems[msg.sender].length - 1
];
userRedeems[msg.sender].pop();
}
function _beforeTokenTransfer(
address from,
address to,
uint256
) internal view override {
require(
from == address(0) ||
_transferWhitelist.contains(from) ||
_transferWhitelist.contains(to),
"transfer: not allowed"
);
}
function _currentBlockTimestamp() internal view virtual returns (uint256) {
return block.timestamp;
}
}
{
"compilationTarget": {
"contracts/XSynthToken.sol": "XSynthToken"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 999999
},
"remappings": []
}
[{"inputs":[{"internalType":"contract ISynthTokenV2","name":"_synthToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Allocate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ApproveUsage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"xSynthAmount","type":"uint256"}],"name":"CancelRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Convert","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Deallocate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"xSynthAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"synthAmount","type":"uint256"}],"name":"FinalizeRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"xSynthAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"synthAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"add","type":"bool"}],"name":"SetTransferWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usageAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"UpdateDeallocationFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousDividendsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newDividendsAddress","type":"address"}],"name":"UpdateDividendsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"previousDividendsAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newDividendsAddress","type":"address"}],"name":"UpdateRedeemDividendsAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minRedeemRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxRedeemRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minRedeemDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxRedeemDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemDividendsAdjustment","type":"uint256"}],"name":"UpdateRedeemSettings","type":"event"},{"inputs":[],"name":"MAX_DEALLOCATION_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FIXED_RATIO","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"usageData","type":"bytes"}],"name":"allocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"allocateFromUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IXSynthTokenUsage","name":"usage","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"cancelRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"convert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"convertTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"usageData","type":"bytes"}],"name":"deallocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deallocateFromUsage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dividendsAddress","outputs":[{"internalType":"contract IXSynthTokenUsage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"finalizeRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"getSynthByVestingDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"usageAddress","type":"address"}],"name":"getUsageAllocation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"usageAddress","type":"address"}],"name":"getUsageApproval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"getUserRedeem","outputs":[{"internalType":"uint256","name":"synthAmount","type":"uint256"},{"internalType":"uint256","name":"xSynthAmount","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"address","name":"dividendsContract","type":"address"},{"internalType":"uint256","name":"dividendsAllocation","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserRedeemsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getXSynthBalance","outputs":[{"internalType":"uint256","name":"allocatedAmount","type":"uint256"},{"internalType":"uint256","name":"redeemingAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isTransferWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemDurationDividendAdjust","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxRedeemRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRedeemDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRedeemRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"xSynthAmount","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemDividendsAdjustment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"synthToken","outputs":[{"internalType":"contract ISynthTokenV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"transferWhitelist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferWhitelistLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usageAddress","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"updateDeallocationFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IXSynthTokenUsage","name":"dividendsAddress_","type":"address"}],"name":"updateDividendsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxRedeemDurationDividendAdjust","type":"uint256"}],"name":"updateMaxDurationRedeemDividendsAdjst","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemIndex","type":"uint256"}],"name":"updateRedeemDividendsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemDividendsAdjustment_","type":"uint256"}],"name":"updateRedeemDividendsAdjustment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minRedeemRatio_","type":"uint256"},{"internalType":"uint256","name":"maxRedeemRatio_","type":"uint256"},{"internalType":"uint256","name":"minRedeemDuration_","type":"uint256"},{"internalType":"uint256","name":"maxRedeemDuration_","type":"uint256"},{"internalType":"uint256","name":"redeemDividendsAdjustment_","type":"uint256"}],"name":"updateRedeemSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"add","type":"bool"}],"name":"updateTransferWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"usageAllocations","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"usageApprovals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"usagesDeallocationFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userRedeems","outputs":[{"internalType":"uint256","name":"synthAmount","type":"uint256"},{"internalType":"uint256","name":"xSynthAmount","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"contract IXSynthTokenUsage","name":"dividendsAddress","type":"address"},{"internalType":"uint256","name":"dividendsAllocation","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"xSynthBalances","outputs":[{"internalType":"uint256","name":"allocatedAmount","type":"uint256"},{"internalType":"uint256","name":"redeemingAmount","type":"uint256"}],"stateMutability":"view","type":"function"}]