DexVault
The DexVault smart contract is used for creating vault and filling initial data.
Last updated
The DexVault smart contract is used for creating vault and filling initial data.
Last updated
Smart contract responsible for creating vault and filling initial data such as lp token, platform code, owner and manipulating vault’s transactions (transfer, withdraw).
Derives following classes and interfaces: DexContractBase, IDexVault, IUpgradable, IResetGas.
constructor
Sets gas limit to maximum (tvm.accept
) and sets values for root, owner and token factory address.
Parameters:
Name | Type | Description |
---|---|---|
_dexRoot
Returns the root address of the DexVault.
Return value:
Type | Description |
---|---|
transferOwner
Pending owner address gets value of the new owner param which is used in acceptOwner method (where actual transfer of ownership is happening) and emits RequestedOwnerTransfer
event.
Parameters:
acceptOwner
Accepts new owner in a way that owner becomes pending owner and emits OwnerTransferAccepted
event.
getOwner
Returns DexVault owner address.
Return value:
getPendingOwner
Returns DexVault’s pending owner address.
Return value:
setTokenFactory
Sets new address of token factory by passing new address from function params to token factory contract param, emits TokenFactoryAddressUpdated event with previous token factory address and a new one.
Parameters:
installPlatformOnce
Checks whether the platform is already installed, if not, reserves initial balance, passes code value to the platform code and transfers gas.
Parameters:
installOrUpdateLpTokenPendingCode
Reserves initial balance, passes new code to lp token pending code.
Parameters:
addLiquidityToken
Creates new instance of DexVaultLpTokenPending
, pass necessary params such as token factory address, value and address for receiving gas.
Parameters:
onLiquidityTokenDeployed
Callback function, builds initial token pending data based on the params passed by onlyLpTokenPending
, reserves initial balance calls the liquidityTokenRootDeployed
method from the DexPair where the token root wallets are configured and the new pair is created.
Parameters:
onLiquidityTokenNotDeployed
Callback function, builds initial token pending data based on the params passed by onlyLpTokenPending
, calls the liquidityTokenRootNotDeployed
method from the DexPair where it does the transfer from send_gas_to
address based on active variable.
Parameters:
_buildLpTokenPendingInitData
Builds pending liquidity pool token initial data calling tvm’s buildStateInit method where it returns TvmCell with initialized state using DexVaultLpTokenPending
contract, additional data for the contract such as nonce, vault, pair, left, right address and lp_token_pending_code
as required code param for buildStateInit method
Parameters:
Return value:
withdraw
Used for withdraw transaction, called from dex pair, transfers tokens from vault token wallet to recipient address through the transfer method from TokenWallet.
Emits WithdrawToken
event and calls successCallback
to notify success.
Parameters:
transfer
Does the pair transfer tokens through the transfer method of the TokenWallet from vault wallet to the recipient’s address, emits PairTransferTokens
event.
Parameters:
upgrade
function upgrade(TvmCell code) public override onlyOwner
Reserves initial balance, makes new builder instance to store all the vault’s data necessary, set passed code for upgrade and finishes upgrade of DexVault by calling onCodeUpgrade
Return value:
resetGas
Resets balance to ROOT_INITIAL_BALANCE
.
Return value:
resetTargetGas
Calculates max between ROOT_INITIAL_BALANCE
and after that resets gas to calculated value for target address calling resetGas
method.
Return value:
VaultCodeUpgraded
Emitted when vault code is upgraded
RequestedOwnerTransfer
Emitted when ownership transfer is requested.
OwnerTransferAccepted
Emitted when ownership transfer is accepted.
TokenFactoryAddressUpdated
Emitted when old token factory address is replaced with new one.
WithdrawTokens
PairTransferTokens
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Type | Description |
---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
owner_
address
Address of the dex vault owner
root_
address
Address of the dex vault root
token_factory_
address
Address of the token factory
address
Address of the dex root
new_owner
address
Address of the new vault owner
address
address
Address of the pending owner of the dex vault
new_token_factory
address
Address of the new token factory
code
TvmCell
Platform code for initial version
code
TvmCell
Liquidity pool pending code
pair
address
Pair address
left_root
address
Token root address of the left token
right_root
address
Token root address of the right token
send_gas_to
address
Address where to send gas spent by calling contract methods
nonce
uint32
Flag used in building initial state of tvm
pair
address
Address of the liquidity pool
left_root
address
Token root address of the left token
right_root
address
Token root address of the right token
lp_root
address
Liquidity pool root address
send_gas_to
address
Address where to send gas spent by calling contract methods
nonce
uint32
Flag used in building initial state of tvm
pair
address
Address of the liquidity pool
left_root
address
Token root address of the left token
right_root
address
Token root address of the right token
lp_root
address
Liquidity pool root address
send_gas_to
address
Address where to send gas spent by calling contract methods
nonce
uint32
Flag used in building initial state of tvm
pair
address
Address of the liquidity pool
left_root
address
Token root address of the left token
right_root
address
Token root address of the right token
TvmCell
Data used for building initial state
nonce
uint32
Flag used in building initial state of tvm
pair
address
Address of the liquidity pool
left_root
address
Token root address of the left token
right_root
address
Token root address of the right token
lp_root
address
Liquidity pool root address
send_gas_to
address
Address where to send gas spent by calling contract methods
amount
uint128
Amount to be transferred
token_root
address
Address of the token root which will be transferred
vault_wallet
address
Address of vault’s wallet
recipient_address
address
Address of the recipient of the transaction
deploy_wallet_grams
uint128
Fee for deploying wallet
notify_receiver
bool
Indicates if the receiver of the transaction should be notified
payload
TvmCell
Additional data needed for transfering to token wallet
left_root
address
Token root address of the left token
right_root
address
Token root address of the right token
pair_version
uint32
Current pair version
send_gas_to
address
Address where to send gas spent by calling contract methods
code
TvmCell
Code to be set for upgraded version
receiver
address
Address where to send gas spent by calling contract methods
target
address
Address for which gas should be reset
receiver
address
Address where to send gas spent by calling contract methods