# GToken

*GToken vault contract, direct counterparty to trades happening on gTrade*

## gnsToken

```solidity
address gnsToken
```

## lockedDepositNft

```solidity
contract IGTokenLockedDepositNft lockedDepositNft
```

## manager

```solidity
address manager
```

## admin

```solidity
address admin
```

## pnlHandler

```solidity
address pnlHandler
```

## openTradesPnlFeed

```solidity
contract IGTokenOpenPnlFeed openTradesPnlFeed
```

## gnsPriceProvider

```solidity
struct IGToken.GnsPriceProvider gnsPriceProvider
```

## PRECISION\_18

```solidity
uint256 PRECISION_18
```

## PRECISION\_10

```solidity
uint256 PRECISION_10
```

## MIN\_DAILY\_ACC\_PNL\_DELTA

```solidity
uint256 MIN_DAILY_ACC_PNL_DELTA
```

## MAX\_SUPPLY\_INCREASE\_DAILY\_P

```solidity
uint256 MAX_SUPPLY_INCREASE_DAILY_P
```

## MAX\_LOSSES\_BURN\_P

```solidity
uint256 MAX_LOSSES_BURN_P
```

## MAX\_GNS\_SUPPLY\_MINT\_DAILY\_P

```solidity
uint256 MAX_GNS_SUPPLY_MINT_DAILY_P
```

## MAX\_DISCOUNT\_P

```solidity
uint256 MAX_DISCOUNT_P
```

## MIN\_LOCK\_DURATION

```solidity
uint256 MIN_LOCK_DURATION
```

## MAX\_LOCK\_DURATION

```solidity
uint256 MAX_LOCK_DURATION
```

## WITHDRAW\_EPOCHS\_LOCKS

```solidity
uint256[] WITHDRAW_EPOCHS_LOCKS
```

## maxAccOpenPnlDelta

```solidity
uint256 maxAccOpenPnlDelta
```

## maxDailyAccPnlDelta

```solidity
uint256 maxDailyAccPnlDelta
```

## withdrawLockThresholdsP

```solidity
uint256[2] withdrawLockThresholdsP
```

## maxSupplyIncreaseDailyP

```solidity
uint256 maxSupplyIncreaseDailyP
```

## lossesBurnP

```solidity
uint256 lossesBurnP
```

## maxGnsSupplyMintDailyP

```solidity
uint256 maxGnsSupplyMintDailyP
```

## maxDiscountP

```solidity
uint256 maxDiscountP
```

## maxDiscountThresholdP

```solidity
uint256 maxDiscountThresholdP
```

## shareToAssetsPrice

```solidity
uint256 shareToAssetsPrice
```

## accPnlPerTokenUsed

```solidity
int256 accPnlPerTokenUsed
```

## accPnlPerToken

```solidity
int256 accPnlPerToken
```

## accRewardsPerToken

```solidity
uint256 accRewardsPerToken
```

## dailyAccPnlDelta

```solidity
int256 dailyAccPnlDelta
```

## lastDailyAccPnlDeltaReset

```solidity
uint256 lastDailyAccPnlDeltaReset
```

## currentEpoch

```solidity
uint256 currentEpoch
```

## currentEpochStart

```solidity
uint256 currentEpochStart
```

## currentEpochPositiveOpenPnl

```solidity
uint256 currentEpochPositiveOpenPnl
```

## currentMaxSupply

```solidity
uint256 currentMaxSupply
```

## lastMaxSupplyUpdate

```solidity
uint256 lastMaxSupplyUpdate
```

## withdrawRequests

```solidity
mapping(address => mapping(uint256 => uint256)) withdrawRequests
```

## lockedDepositsCount

```solidity
uint256 lockedDepositsCount
```

## lockedDeposits

```solidity
mapping(uint256 => struct IGToken.LockedDeposit) lockedDeposits
```

## assetsToDeplete

```solidity
uint256 assetsToDeplete
```

## dailyMintedGns

```solidity
uint256 dailyMintedGns
```

## lastDailyMintedGnsReset

```solidity
uint256 lastDailyMintedGnsReset
```

## totalDeposited

```solidity
uint256 totalDeposited
```

## totalClosedPnl

```solidity
int256 totalClosedPnl
```

## totalRewards

```solidity
uint256 totalRewards
```

## totalLiability

```solidity
int256 totalLiability
```

## totalLockedDiscounts

```solidity
uint256 totalLockedDiscounts
```

## totalDiscounts

```solidity
uint256 totalDiscounts
```

## totalDepleted

```solidity
uint256 totalDepleted
```

## totalDepletedGns

```solidity
uint256 totalDepletedGns
```

## totalRefilled

```solidity
uint256 totalRefilled
```

## totalRefilledGns

```solidity
uint256 totalRefilledGns
```

## accBlockWeightedMarketCap

```solidity
uint256 accBlockWeightedMarketCap
```

## accBlockWeightedMarketCapLastStored

```solidity
uint256 accBlockWeightedMarketCapLastStored
```

## collateralConfig

```solidity
struct CollateralUtils.CollateralConfig collateralConfig
```

## initialize

```solidity
function initialize(struct IGToken.Meta _meta, struct IGToken.ContractAddresses _contractAddresses, uint256 _MIN_LOCK_DURATION, uint256 _maxAccOpenPnlDelta, uint256 _maxDailyAccPnlDelta, uint256[2] _withdrawLockThresholdsP, uint256 _maxSupplyIncreaseDailyP, uint256 _lossesBurnP, uint256 _maxGnsSupplyMintDailyP, uint256 _maxDiscountP, uint256 _maxDiscountThresholdP) external
```

## initializeV3

```solidity
function initializeV3() external
```

## onlyManager

```solidity
modifier onlyManager()
```

## checks

```solidity
modifier checks(uint256 assetsOrShares)
```

## validDiscount

```solidity
modifier validDiscount(uint256 lockDuration)
```

## transferOwnership

```solidity
function transferOwnership(address newOwner) public
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

## updateManager

```solidity
function updateManager(address newValue) external
```

## updateAdmin

```solidity
function updateAdmin(address newValue) external
```

## updatePnlHandler

```solidity
function updatePnlHandler(address newValue) external
```

## updateGnsPriceProvider

```solidity
function updateGnsPriceProvider(struct IGToken.GnsPriceProvider newValue) external
```

## updateOpenTradesPnlFeed

```solidity
function updateOpenTradesPnlFeed(address newValue) external
```

## updateDelegatee

```solidity
function updateDelegatee(address _delegatee) external
```

## updateMaxAccOpenPnlDelta

```solidity
function updateMaxAccOpenPnlDelta(uint256 newValue) external
```

## updateMaxDailyAccPnlDelta

```solidity
function updateMaxDailyAccPnlDelta(uint256 newValue) external
```

## updateWithdrawLockThresholdsP

```solidity
function updateWithdrawLockThresholdsP(uint256[2] newValue) external
```

## updateMaxSupplyIncreaseDailyP

```solidity
function updateMaxSupplyIncreaseDailyP(uint256 newValue) external
```

## updateLossesBurnP

```solidity
function updateLossesBurnP(uint256 newValue) external
```

## updateMaxGnsSupplyMintDailyP

```solidity
function updateMaxGnsSupplyMintDailyP(uint256 newValue) external
```

## updateMaxDiscountP

```solidity
function updateMaxDiscountP(uint256 newValue) external
```

## updateMaxDiscountThresholdP

```solidity
function updateMaxDiscountThresholdP(uint256 newValue) external
```

## maxAccPnlPerToken

```solidity
function maxAccPnlPerToken() public view returns (uint256)
```

## collateralizationP

```solidity
function collateralizationP() public view returns (uint256)
```

## gnsTokenToAssetsPrice

```solidity
function gnsTokenToAssetsPrice() public view returns (uint256 price)
```

## withdrawEpochsTimelock

```solidity
function withdrawEpochsTimelock() public view returns (uint256)
```

## lockDiscountP

```solidity
function lockDiscountP(uint256 collatP, uint256 lockDuration) public view returns (uint256)
```

## totalSharesBeingWithdrawn

```solidity
function totalSharesBeingWithdrawn(address owner) public view returns (uint256 shares)
```

## tryUpdateCurrentMaxSupply

```solidity
function tryUpdateCurrentMaxSupply() public
```

## tryResetDailyAccPnlDelta

```solidity
function tryResetDailyAccPnlDelta() public
```

## tryNewOpenPnlRequestOrEpoch

```solidity
function tryNewOpenPnlRequestOrEpoch() public
```

## transfer

```solidity
function transfer(address to, uint256 amount) public returns (bool)
```

## transferFrom

```solidity
function transferFrom(address from, address to, uint256 amount) public returns (bool)
```

## decimals

```solidity
function decimals() public view returns (uint8)
```

## \_convertToShares

```solidity
function _convertToShares(uint256 assets, enum MathUpgradeable.Rounding rounding) internal view returns (uint256 shares)
```

*Internal conversion function (from assets to shares) with support for rounding direction.*

## \_convertToAssets

```solidity
function _convertToAssets(uint256 shares, enum MathUpgradeable.Rounding rounding) internal view returns (uint256 assets)
```

*Internal conversion function (from shares to assets) with support for rounding direction.*

## maxMint

```solidity
function maxMint(address) public view returns (uint256)
```

*See {IERC4626-maxMint}.*

## maxDeposit

```solidity
function maxDeposit(address owner) public view returns (uint256)
```

## maxRedeem

```solidity
function maxRedeem(address owner) public view returns (uint256)
```

*See {IERC4626-maxRedeem}.*

## maxWithdraw

```solidity
function maxWithdraw(address owner) public view returns (uint256)
```

*See {IERC4626-maxWithdraw}.*

## deposit

```solidity
function deposit(uint256 assets, address receiver) public returns (uint256)
```

*See {IERC4626-deposit}.*

## mint

```solidity
function mint(uint256 shares, address receiver) public returns (uint256)
```

\_See {IERC4626-mint}.

As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero. In this case, the shares will be minted without requiring any assets to be deposited.\_

## withdraw

```solidity
function withdraw(uint256 assets, address receiver, address owner) public returns (uint256)
```

*See {IERC4626-withdraw}.*

## redeem

```solidity
function redeem(uint256 shares, address receiver, address owner) public returns (uint256)
```

*See {IERC4626-redeem}.*

## makeWithdrawRequest

```solidity
function makeWithdrawRequest(uint256 shares, address owner) external
```

## cancelWithdrawRequest

```solidity
function cancelWithdrawRequest(uint256 shares, address owner, uint256 unlockEpoch) external
```

## depositWithDiscountAndLock

```solidity
function depositWithDiscountAndLock(uint256 assets, uint256 lockDuration, address receiver) external returns (uint256)
```

## mintWithDiscountAndLock

```solidity
function mintWithDiscountAndLock(uint256 shares, uint256 lockDuration, address receiver) external returns (uint256)
```

## unlockDeposit

```solidity
function unlockDeposit(uint256 depositId, address receiver) external
```

## distributeReward

```solidity
function distributeReward(uint256 assets) external
```

## sendAssets

```solidity
function sendAssets(uint256 assets, address receiver) external
```

## receiveAssets

```solidity
function receiveAssets(uint256 assets, address user) external
```

## deplete

```solidity
function deplete(uint256 assets) external
```

## refill

```solidity
function refill(uint256 assets) external
```

## updateAccPnlPerTokenUsed

```solidity
function updateAccPnlPerTokenUsed(uint256 prevPositiveOpenPnl, uint256 newPositiveOpenPnl) external returns (uint256)
```

## getLockedDeposit

```solidity
function getLockedDeposit(uint256 depositId) external view returns (struct IGToken.LockedDeposit)
```

## tvl

```solidity
function tvl() public view returns (uint256)
```

## availableAssets

```solidity
function availableAssets() public view returns (uint256)
```

## marketCap

```solidity
function marketCap() public view returns (uint256)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gains.trade/developer/technical-reference/contracts/core/gtoken.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
