V2 矿池 Functions

获取矿池信息

sub_pool

function sub_pool().call()
  • 描述:查看定期矿池地址

  • 调用合约:gauge 合约

  • 参数:None

  • 返回值:矿池地址

  • 示例:查看 USDDOLD 2pool LP (USDDOLD+USDT) 的矿池地址

// sub_pool  USDDOLD 2pool LP ( USDDOLD + USDT ) 定期
const gauge_con = await tronWeb.contract(gaugeabi, gauge_addr)
const subpool_ = await gauge_con.sub_pool().call()
console.log(tronWeb.address.fromHex(subpool_))
  • 返回

TUgVp8FzZcFLHwruuncXaQo2js5Ym2GqSj

earned

function earned(
    address account,
).call()
  • 描述:查看活期奖励

  • 调用合约:矿池合约

  • 参数:

参数名
类型
描述

account

address

用户地址

  • 返回值:活期奖励数量

  • 示例:查看 USDDOLD 2pool LP (USDDOLD+USDT) 矿池活期奖励

const farm_con = await tronWeb.contract(farmabi, farm_addr)
const earned_ = await farm_con.earned(self_address).call()
console.log(earned_)

执行交易

deposit(活期)

function deposit(
    uint256 _value,
).call()
  • 描述:活期存款

  • 调用合约:gauge 合约

  • 参数:

参数名
类型
描述

_value

uint256

存款金额

  • 返回值:交易 hash

  • 示例:向 USDDOLD 2pool LP (USDDOLD+USDT) 矿池活期存款

const gauge_con = await tronWeb.contract(gaugeabi, gauge_addr)
const deposit_ = await gauge_con.deposit(100).send()
console.log(deposit_)

deposit(定期)

function deposit(
    uint256 _value,
    address addr,
    uint256 _lock_duration,
).call()
  • 描述:定期存款

  • 调用合约:gauge 合约

  • 参数:

参数名
类型
描述

_value

uint256

存款金额

addr

address

用户地址

_lock_duration

uint256

存款时长,按秒计算

  • 返回值:交易 hash

  • 示例:向 USDDOLD 2pool LP (USDDOLD+USDT) 矿池定期存款30天

const gauge_con = await tronWeb.contract(gaugeabi, gauge_addr)
const deposit_ = await gauge_con.deposit(100, self_address, 259200).send() //259200 = 30天
console.log(deposit_)

withdraw

function withdraw(
    uint256 _value,
).call()
  • 描述:取款

  • 调用合约:gauge 合约

  • 参数:

参数名
类型
描述

_value

uint256

取款金额

  • 返回值:交易 hash

  • 示例:从 USDDOLD 2pool LP (USDDOLD+USDT) 矿池取款

const gauge_con = await tronWeb.contract(gaugeabi, gauge_addr)
const withdraw_ = await gauge_con.withdraw(50).send() //withdraw(0) 领取所有奖励包括质押奖励和治理奖励
console.log(withdraw_)

Note: 如想一并提取质押奖励和治理奖励可以使用 withdraw(0)。

Last updated