将 erc-20 代币的价格与加密货币挂钩

Peg erc-20 token's price to a cryptocoin

任何人都可以向我解释映射或挂钩发生的位置吗?以价格与黄金挂钩的 PAXG 为例。我如何使用我的 erc-20 令牌来做到这一点?是写在代码里还是跟交易所有关系?

其中大部分与代币代码无关,属于经济学话题。这是 Whosebug 的题外话,所以我只想简单地说一些只有部分正确的话:只要有足够多的买家和卖家愿意 buy/sell 代币换取黄金价格,代币就会有黄金价格。


但是,您可以在合约中定义控制其总供应量的函数,这会影响价格(有时会再次影响价格 - 经济学)。

看看PAXGsource code:

/**
 * @dev Increases the total supply by minting the specified number of tokens to the supply controller account.
 * @param _value The number of tokens to add.
 * @return A boolean that indicates if the operation was successful.
 */
function increaseSupply(uint256 _value) public onlySupplyController returns (bool success) {
    totalSupply_ = totalSupply_.add(_value);
    balances[supplyController] = balances[supplyController].add(_value);
    emit SupplyIncreased(supplyController, _value);
    emit Transfer(address(0), supplyController, _value);
    return true;
}
/**
 * @dev Decreases the total supply by burning the specified number of tokens from the supply controller account.
 * @param _value The number of tokens to remove.
 * @return A boolean that indicates if the operation was successful.
 */
function decreaseSupply(uint256 _value) public onlySupplyController returns (bool success) {
    require(_value <= balances[supplyController], "not enough supply");
    balances[supplyController] = balances[supplyController].sub(_value);
    totalSupply_ = totalSupply_.sub(_value);
    emit SupplyDecreased(supplyController, _value); 
    emit Transfer(supplyController, address(0), _value);
    return true;
}

通过执行这些函数(只能从授权地址执行 - 此检查在 onlySupplyController 修饰符中执行),您可以操纵 [= 值中存在的地址余额13=] 属性.


其他将其价值与某些链下资产挂钩的代币也有一个内置的 buy 函数(有时还有一个 sell 函数)允许 buying/selling代币 from/to 预定义价格的预定义持有者。这也可能会激励买卖双方使用内置功能,而不是在交易所使用利润较低的价格,这可能会有效影响价格。