UNPKG

@goat-sdk/plugin-mode-governance

Version:

<div align="center"> <a href="https://github.com/goat-sdk/goat">

2 lines (1 loc) 3.68 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHMH7EQMVjs = require('./chunk-HMH7EQMV.js');var _chunkVPE4MTWOjs = require('./chunk-VPE4MTWO.js');var _chunk5MFDTNNJjs = require('./chunk-5MFDTNNJ.js');var _chunkEI7MMDWYjs = require('./chunk-EI7MMDWY.js');var _core = require('@goat-sdk/core');var _walletevm = require('@goat-sdk/wallet-evm');var _viem = require('viem');function w(d,e,o,t){var i=arguments.length,n=i<3?e:t===null?t=Object.getOwnPropertyDescriptor(e,o):t,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,o,t);else for(var f=d.length-1;f>=0;f--)(a=d[f])&&(n=(i<3?a(n):i>3?a(e,o,n):a(e,o))||n);return i>3&&n&&Object.defineProperty(e,o,n),n}_chunkEI7MMDWYjs.a.call(void 0, w,"_ts_decorate");function r(d,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(d,e)}_chunkEI7MMDWYjs.a.call(void 0, r,"_ts_metadata");var p=class{static{_chunkEI7MMDWYjs.a.call(void 0, this,"ModeGovernanceService")}async stakeTokensForModeGovernance(e,o){let t=o.tokenType==="MODE"?_chunkVPE4MTWOjs.c:_chunkVPE4MTWOjs.d;return(await e.sendTransaction({to:t,abi:_chunkHMH7EQMVjs.a,functionName:"createLock",args:[_viem.parseUnits.call(void 0, o.amount,18)]})).hash}async getModeGovernanceStakeInfo(e,o){let t=o.tokenType==="MODE"?_chunkVPE4MTWOjs.c:_chunkVPE4MTWOjs.d,i=await e.getAddress(),n=await e.read({address:t,abi:_chunkHMH7EQMVjs.a,functionName:"ownedTokens",args:[i]});if(n.length===0)return{stakedAmount:"0",startTime:0,votingPower:"0",isVoting:!1};let a=n[0],[f,b]=await e.read({address:t,abi:_chunkHMH7EQMVjs.a,functionName:"locked",args:[a]}),T=await e.read({address:t,abi:_chunkHMH7EQMVjs.a,functionName:"votingPower",args:[a]}),M=await e.read({address:t,abi:_chunkHMH7EQMVjs.a,functionName:"isVoting",args:[a]});return{stakedAmount:_viem.formatUnits.call(void 0, f,18),startTime:Number(b),votingPower:_viem.formatUnits.call(void 0, T,18),isVoting:M}}async getModeGovernanceVotingPower(e,o){let t=o.address||await e.getAddress();switch(o.tokenType){case"MODE":case"veMode":return _viem.formatUnits.call(void 0, await e.read({address:_chunkVPE4MTWOjs.c,abi:_chunkHMH7EQMVjs.a,functionName:"votingPowerForAccount",args:[t]}),18);case"BPT":case"veBPT":return _viem.formatUnits.call(void 0, await e.read({address:_chunkVPE4MTWOjs.d,abi:_chunkHMH7EQMVjs.a,functionName:"votingPowerForAccount",args:[t]}),18);default:throw new Error("Invalid token type")}}};w([_core.Tool.call(void 0, {description:"Stake MODE or BPT tokens in the Mode governance system. Requires MODE or BPT tokens to be approved first."}),r("design:type",Function),r("design:paramtypes",[typeof _walletevm.EVMWalletClient>"u"?Object:_walletevm.EVMWalletClient,typeof _chunk5MFDTNNJjs.a>"u"?Object:_chunk5MFDTNNJjs.a]),r("design:returntype",Promise)],p.prototype,"stakeTokensForModeGovernance",null);w([_core.Tool.call(void 0, {description:"Get Mode governance staking information including lock period and voting power"}),r("design:type",Function),r("design:paramtypes",[typeof _walletevm.EVMWalletClient>"u"?Object:_walletevm.EVMWalletClient,typeof _chunk5MFDTNNJjs.b>"u"?Object:_chunk5MFDTNNJjs.b]),r("design:returntype",Promise)],p.prototype,"getModeGovernanceStakeInfo",null);w([_core.Tool.call(void 0, {description:"Get the Mode governance voting power for any address. Use 'veMode' or 'veBPT' to check voting power."}),r("design:type",Function),r("design:paramtypes",[typeof _walletevm.EVMWalletClient>"u"?Object:_walletevm.EVMWalletClient,typeof _chunk5MFDTNNJjs.c>"u"?Object:_chunk5MFDTNNJjs.c]),r("design:returntype",Promise)],p.prototype,"getModeGovernanceVotingPower",null);exports.a = p;