跳转到主要内容

合约信息

属性
地址通过 MemeFactory.bondingCurve() 读取(MemeFactory 地址见合约地址
网络Kasplex(见合约地址
所有计算函数都是 pure 的——不读取也不修改状态。你可以在链下调用它们进行免 gas 的价格查询。

函数

calculateBuyReturnWithParams

计算给定 KAS 数量能获得多少代币。
function calculateBuyReturnWithParams(
    uint256 kasIn,
    uint256 tokenReserves,
    uint256 kasReserves,
    uint256 vToken,
    uint256 vKas
) external pure returns (uint256 tokensOut)
参数类型说明
kasInuint256花费的 KAS 数量 (wei)
tokenReservesuint256当前代币储备,来自 getTokenInfo()
kasReservesuint256当前 KAS 储备,来自 getTokenInfo()
vTokenuint256虚拟代币,来自 getTokenParamVersion()
vKasuint256虚拟 KAS,来自 getTokenParamVersion()

calculateSellReturnWithParams

计算卖出代币能获得多少 KAS。
function calculateSellReturnWithParams(
    uint256 tokensIn,
    uint256 tokenReserves,
    uint256 kasReserves,
    uint256 vToken,
    uint256 vKas
) external pure returns (uint256 kasOut)
参数类型说明
tokensInuint256卖出的代币数量 (wei)
tokenReservesuint256当前代币储备,来自 getTokenInfo()
kasReservesuint256当前 KAS 储备,来自 getTokenInfo()
vTokenuint256虚拟代币,来自 getTokenParamVersion()
vKasuint256虚拟 KAS,来自 getTokenParamVersion()

calculateBuyCostWithParams

计算要获得指定数量代币需要花费多少 KAS。
function calculateBuyCostWithParams(
    uint256 tokensOut,
    uint256 tokenReserves,
    uint256 kasReserves,
    uint256 vToken,
    uint256 vKas
) external pure returns (uint256 kasIn)
参数类型说明
tokensOutuint256期望的代币数量 (wei)
tokenReservesuint256当前代币储备,来自 getTokenInfo()
kasReservesuint256当前 KAS 储备,来自 getTokenInfo()
vTokenuint256虚拟代币,来自 getTokenParamVersion()
vKasuint256虚拟 KAS,来自 getTokenParamVersion()

getCurrentPrice

获取当前现货价格。
function getCurrentPrice(
    uint256 tokenReserves,
    uint256 kasReserves
) external view returns (uint256 price)

virtualToken / virtualKas

function virtualToken() external view returns (uint256)
function virtualKas() external view returns (uint256)
BondingCurve 合约中配置的默认虚拟储备。注意:各代币可能通过 getTokenParamVersion() 使用不同的值。

curveType

function curveType() external view returns (uint256)
返回曲线类型标识符。

完整 ABI (JSON)

[
  {
    "inputs": [{"internalType": "uint256", "name": "kasIn", "type": "uint256"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "vToken", "type": "uint256"}, {"internalType": "uint256", "name": "vKas", "type": "uint256"}],
    "name": "calculateBuyReturnWithParams",
    "outputs": [{"internalType": "uint256", "name": "tokensOut", "type": "uint256"}],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [{"internalType": "uint256", "name": "tokensOut", "type": "uint256"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "vToken", "type": "uint256"}, {"internalType": "uint256", "name": "vKas", "type": "uint256"}],
    "name": "calculateBuyCostWithParams",
    "outputs": [{"internalType": "uint256", "name": "kasIn", "type": "uint256"}],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [{"internalType": "uint256", "name": "tokensIn", "type": "uint256"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "vToken", "type": "uint256"}, {"internalType": "uint256", "name": "vKas", "type": "uint256"}],
    "name": "calculateSellReturnWithParams",
    "outputs": [{"internalType": "uint256", "name": "kasOut", "type": "uint256"}],
    "stateMutability": "pure",
    "type": "function"
  },
  {
    "inputs": [{"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}],
    "name": "getCurrentPrice",
    "outputs": [{"internalType": "uint256", "name": "price", "type": "uint256"}],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "virtualToken",
    "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "virtualKas",
    "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "curveType",
    "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
    "stateMutability": "view",
    "type": "function"
  }
]