hedgey-sdk v6.1.26
Hedgey SDK
Contains utilities and helpers used by the hedgey frontend apps.
Installation
To install the latest version run:
npm install hedgey-sdk --saveModules
v2.streamVestingNft
Table of contents
Functions
- createBatch
- createLockedBatch
- createLockedNFT
- delegateAllNFTs
- delegateTokens
- redeemAllNFTs
- redeemNFTs
- revokeNFTs
Functions
createBatch
createBatch(web3, contractAddress, batchVesterContractAddress, sender, recipients, token, amounts, starts, cliffs, rates, vestingAdmin, mintType, safeDetails, timeout?): Promise<TransactionResult>
Create a batch of locked NFTs with a vesting schedule
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
contractAddress | string | The stream vesting NFT contract |
batchVesterContractAddress | string | The batch contract address |
sender | string | The address executing this transaction |
recipients | string[] | The recipients of the NFT |
token | string | The token to lock |
amounts | string[] | The amounts of tokens to lock |
starts | Date[] | The start dates |
cliffs | Date[] | The cliff dates |
rates | string[] | The rates |
vestingAdmin | string | An admin address for this vesting schedule |
mintType | number | An integer representing the product |
safeDetails | SafeDetails | The details of the safe |
timeout? | number | A timeout for requests |
Returns
Promise<TransactionResult>
The transaction result
Defined in
src/v2/stream.vesting.nft.ts:147
createLockedBatch
createLockedBatch(web3, contractAddress, batchVesterContractAddress, sender, recipients, token, amounts, starts, cliffs, rates, vestingAdmin, unlockDates, transferableNFTLocker, mintType, safeDetails, timeout?): Promise<TransactionResult>
Create a batch of locked vesting NFTs
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
contractAddress | string | The contract address |
batchVesterContractAddress | string | The batch contract address |
sender | string | The address executing this transaction |
recipients | string[] | An array of recipients |
token | string | The token to lock |
amounts | string[] | The amounts of tokens to lock |
starts | Date[] | The start dates |
cliffs | Date[] | The cliff dates |
rates | string[] | The rates |
vestingAdmin | string | An admin address for this vesting schedule |
unlockDates | Date[] | The unlock dates |
transferableNFTLocker | boolean | The NFT to transfer remaining tokens to lock |
mintType | number | An integer representing the product |
safeDetails | SafeDetails | The details of the safe |
timeout? | number | A timeout for requests |
Returns
Promise<TransactionResult>
The transaction result
Defined in
src/v2/stream.vesting.nft.ts:258
createLockedNFT
createLockedNFT(web3, contractAddress, sender, recipient, token, amount, start, cliffDate, rate, vestingAdmin, unlockDate, transferableNFTLocker, safeDetails, timeout?): Promise<TransactionResult>
Create a locked NFT with a vesting schedule
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
contractAddress | string | The stream vesting NFT contract |
sender | string | The address executing this transaction |
recipient | string | The recipient of the NFT |
token | string | The token to lock |
amount | string | The amount of tokens to lock |
start | Date | The start date |
cliffDate | Date | The cliff date |
rate | string | The rate |
vestingAdmin | string | An admin address for this vesting schedule |
unlockDate | Date | The unlock date |
transferableNFTLocker | boolean | The NFT to transfer remaining tokens to lock |
safeDetails | SafeDetails | The details of the safe |
timeout? | number | A timeout for requests |
Returns
Promise<TransactionResult>
The transaction result
Defined in
src/v2/stream.vesting.nft.ts:37
delegateAllNFTs
delegateAllNFTs(web3, accountAddress, delegateAddress, contractAddress, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
delegateAddress | string |
contractAddress | string |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
src/v2/stream.vesting.nft.ts:392
delegateTokens
delegateTokens(web3, accountAddress, delegateAddress, contractAddress, tokenIds, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
delegateAddress | string |
contractAddress | string |
tokenIds | number[] |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
src/v2/stream.vesting.nft.ts:411
redeemAllNFTs
redeemAllNFTs(web3, accountAddress, contractAddress, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
contractAddress | string |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
src/v2/stream.vesting.nft.ts:375
redeemNFTs
redeemNFTs(web3, contractAddress, accountAddress, tokenIds, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
contractAddress | string |
accountAddress | string |
tokenIds | number[] |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
src/v2/stream.vesting.nft.ts:432
revokeNFTs
revokeNFTs(web3, accountAddress, contractAddress, tokenIds, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
contractAddress | string |
tokenIds | number[] |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
src/v2/stream.vesting.nft.ts:356
v2.streamBoundNft
Table of contents
Functions
Functions
createNFT
createNFT(web3, contractAddress, sender, recipient, token, amount, start, cliffDate, rate, safeDetails, timeout): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
contractAddress | string |
sender | string |
recipient | string |
token | string |
amount | string |
start | Date |
cliffDate | Date |
rate | string |
safeDetails | SafeDetails |
timeout | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
delegateAllNFTs
delegateAllNFTs(web3, accountAddress, delegateAddress, contractAddress, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
delegateAddress | string |
contractAddress | string |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
delegateTokens
delegateTokens(web3, accountAddress, delegateAddress, contractAddress, tokenIds, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
delegateAddress | string |
contractAddress | string |
tokenIds | number[] |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
redeemAllNFTs
redeemAllNFTs(web3, accountAddress, contractAddress, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
accountAddress | string |
contractAddress | string |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
redeemNFTs
redeemNFTs(web3, contractAddress, accountAddress, tokenIds, safeDetails, timeout?): Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Parameters
| Name | Type |
|---|---|
web3 | default |
contractAddress | string |
accountAddress | string |
tokenIds | number[] |
safeDetails | SafeDetails |
timeout? | number |
Returns
Promise<{ pending: boolean = false; safeTransaction: undefined = undefined; timeout: boolean = false; transactionHash: any = results.transactionHash } | { pending: boolean = true; safeTransaction: any = results.safeTxHash; timeout: boolean = false; transactionHash: undefined = undefined }>
Defined in
common
isHedgeyContract
isHedgeyContract(appId, address): Promise<boolean>
Checks the passed address to see if it is a hedgey contract address
Parameters
| Name | Type | Description |
|---|---|---|
appId | string | The realm app ID for graphql |
address | string | The address to check |
Returns
Promise<boolean>
A boolean, true if the address matches on of the configured hedgey contracts
Defined in
V2
Utils
Functions
Functions
prepareAmounts
prepareAmounts(amount, periods, frequency, decimals?): string[]
Prepare an array of amounts
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
amount | string | undefined | The full amount |
periods | number | undefined | The number of periods |
frequency | Frequency | undefined | The frequency |
decimals | undefined | number | undefined | The decimals for the amounts (if undefined amounts are used as is) |
Returns
string[]
An array of amounts represented as strings
Defined in
prepareHolders
prepareHolders(periods, frequency, recipientAddress): string[]
Prepare an array of recipients
Parameters
| Name | Type | Description |
|---|---|---|
periods | number | The number of periods |
frequency | Frequency | The frequency |
recipientAddress | string | The recipient |
Returns
string[]
An array of holders represented as strings
Defined in
prepareUnlockDates
prepareUnlockDates(firstUnlockDate, periods, frequency): string[]
Prepare an array of unlock dates
Parameters
| Name | Type | Description |
|---|---|---|
firstUnlockDate | Date | The first unlock date |
periods | number | The number of periods |
frequency | Frequency | The frequency |
Returns
string[]
An array of dates represented as epoch strings
Defined in
Type Aliases
DistributeResult
DistributeResult: Object
The return type for the Token Distribution
Type declaration
| Name | Type |
|---|---|
pending | boolean |
safeTransaction | string | undefined |
transactionHash | string | undefined |
Defined in
src/v2/token.distribution.ts:21
SafeDetails
SafeDetails: Object
Safe details if the Token Distribution is a gnosis safe
Type declaration
| Name | Type |
|---|---|
attempts | number |
pollInterval | number |
safe | boolean |
Defined in
src/v2/token.distribution.ts:30
Functions
distribute
distribute(web3, batchMintContractAddress, nftContractAddress, tokenAddress, recipientAddress, amount, firstUnlockDate, frequency, sender, periods?, safeDetails?): Promise<DistributeResult>
Creates a Token Distribution
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
web3 | default | undefined | The web3 object |
batchMintContractAddress | string | undefined | The batch mint contract to use |
nftContractAddress | string | undefined | The NFT contract to use |
tokenAddress | string | undefined | The locked token address |
recipientAddress | string | undefined | The recipient address |
amount | string | undefined | The total amount |
firstUnlockDate | Date | undefined | The first unlock date |
frequency | Frequency | undefined | The frequency of the unlock |
sender | string | undefined | The sender address |
periods | number | 1 | The number of periods for unlock |
safeDetails | SafeDetails | undefined | The safe details object |
Returns
Promise<DistributeResult>
The transaction hash or safe transaction hash
Defined in
src/v2/token.distribution.ts:54
SafeDetails
SafeDetails: Object
Type declaration
| Name | Type |
|---|---|
attempts | number |
pollInterval | number |
safe | boolean |
Defined in
src/v2/token.distribution.ts:21
Functions
distribute
distribute(web3, batchMintContractAddress, nftContractAddress, tokenAddress, recipientAddress, amount, firstUnlockDate, frequency, sender, periods?, safeDetails?): Promise<DistributeResult>
Parameters
| Name | Type | Default value |
|---|---|---|
web3 | default | undefined |
batchMintContractAddress | string | undefined |
nftContractAddress | string | undefined |
tokenAddress | string | undefined |
recipientAddress | string | undefined |
amount | string | undefined |
firstUnlockDate | Date | undefined |
frequency | Frequency | undefined |
sender | string | undefined |
periods | number | 1 |
safeDetails | SafeDetails | undefined |
Returns
Promise<DistributeResult>
Defined in
src/v2/token.distribution.ts:29
Safe
ApprovalStatusDetails
ApprovalStatusDetails: Object
Type declaration
| Name | Type |
|---|---|
details? | { confirmations: string[] ; confirmationsRequired: number } |
details.confirmations | string[] |
details.confirmationsRequired | number |
hasApproval | boolean |
Defined in
Functions
approvalStatus
approvalStatus(chainId, safeAddress, contractAddress, token, allowance): Promise<ApprovalStatusDetails>
Returns the approval status from a gnosis safe, if there is an approval transaction queued the details will be returned
Parameters
| Name | Type | Description |
|---|---|---|
chainId | number | The chain ID the gnosis safe contract is deployed on |
safeAddress | string | The safe wallet address |
contractAddress | string | The spender contract address |
token | string | The token contract address |
allowance | string | The allowance needed |
Returns
Promise<ApprovalStatusDetails>
The approval details if there is an approval transaction queued
Defined in
pendingTransactionSubmitted
pendingTransactionSubmitted(chainId, safeAddress, contractAddress, method): Promise<TransactionDetails[]>
Checks a pending transaction exists in a safe, for a transaction using the method name
Parameters
| Name | Type | Description |
|---|---|---|
chainId | number | The chain ID the gnosis safe contract is deployed on |
safeAddress | string | The safe wallet address |
contractAddress | string | The contract the safe is interacting with |
method | string | The method name |
Returns
Promise<TransactionDetails[]>
A boolean, true if a pending transaction exists
Defined in
OTC
batchMintNFTs
batchMintNFTs(web3, address, contractAddress, nftContractAddress, mintingDetails): Promise<any>
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The address of the account used to mint the NFT |
contractAddress | string | The batchMintNFT contract address |
nftContractAddress | string | The NFT contract to call for minting |
mintingDetails | Object | The tokens and recipients to transfer the NFT to |
mintingDetails.recipients | any | - |
mintingDetails.token | TokenInformation | - |
Returns
Promise<any>
Defined in
buyDeal
buyDeal(web3, address, deal, positionSize): Promise<Transaction>
Buy a deal
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
deal | FormattedDeal | The deal to buy from |
positionSize | number | The position size to buy |
Returns
Promise<Transaction>
A promise for the on chain request
Defined in
cancelDeal
cancelDeal(web3, address, contractAddress, dealIndex): Promise<Transaction>
Cancels an open deal
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
contractAddress | string | The deployed contract address |
dealIndex | number | The index of the deal to cancel |
Returns
Promise<Transaction>
The resulting transaction
Defined in
createDeal
createDeal(web3, address, deal): Promise<Transaction>
Creates an OTC deal
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
deal | Deal | The OTC deal to create |
Returns
Promise<Transaction>
The transaction details
Defined in
getLockedTokenDetails
getLockedTokenDetails(web3, contractAddress, walletAddress, contractVersion): Promise<any[]>
Returns the details of the token locked within the NFT
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
contractAddress | string | The contract address |
walletAddress | string | The wallet address |
contractVersion | number | The contract version |
Returns
Promise<any[]>
An array of token details
Defined in
getNFTBalance
getNFTBalance(web3, address, contractAddress, contractVersion): Promise<any>
Returns the number of NFTs in the selected network
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | - |
address | string | The users selected account address from their wallet |
contractAddress | string | The NFT contract address |
contractVersion | number | The version of the NFT contract to use |
Returns
Promise<any>
The balance value
Defined in
listDeals
listDeals(web3, contractAddress): Promise<any[]>
List all deals in the contract
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
contractAddress | string | The contract address |
Returns
Promise<any[]>
An array of deals
Defined in
loadNFTs
loadNFTs(web3, ownerAddress, contractAddress, balance, contractVersion): Promise<{ contract: string ; index: number ; metadata: NFTMetaData }[]>
Returns the meta data for NFTs belonging to the owner address
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
ownerAddress | string | The owner address |
contractAddress | string | The NFT contract address |
balance | number | - |
contractVersion | number | - |
Returns
Promise<{ contract: string ; index: number ; metadata: NFTMetaData }[]>
A list of metadata for NFTs belonging to the owner address
Defined in
redeemNFT
redeemNFT(web3, address, contractAddress, index, contractVersion): Promise<any>
Redeem the NFT
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
contractAddress | string | The NFT contract address |
index | number | The NFT index |
contractVersion | number | The NFT contract version (defaults to 1) |
Returns
Promise<any>
The result of calling the contract
Defined in
transferNFT
transferNFT(web3, address, contractAddress, index, toAddress, contractVersion): Promise<any>
Transfer the NFT
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
contractAddress | string | The NFT contract address |
index | number | The NFT index |
toAddress | string | The address to transfer the NFT to |
contractVersion | number | The NFT contract version |
Returns
Promise<any>
The result of calling the contract
Defined in
Treasury Pools
approveToken
approveToken(web3, address, hedgeyAddress, erc20Address, approvalAmount?): Promise<string>
Gets approval for hedgey to spend from the selected account on behalf of the user
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
hedgeyAddress | string | The hedgey address |
erc20Address | string | The erc20 The currency address |
approvalAmount? | string | An optional amount to use for approval, if not set max value is used |
Returns
Promise<string>
- The transaction hash for the approval transaction
Defined in
buyOption
buyOption(web3, address, option, positionSize): Promise<Transaction>
Calls the relevant hedgey smart contract to buy an option
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
option | Option | The option to buy |
positionSize | number | Amount to buy from the pool |
Returns
Promise<Transaction>
A promise that resolves to the completed transaction
Defined in
src/treasurypools/index.ts:100
cancelOpenOrder
cancelOpenOrder(web3, address, option): Promise<boolean>
Calls the relevant hedgey cancel smart contract to cancel an open option
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The Web3 object |
address | string | The users selected account address from their wallet |
option | Option | The option to cancel |
Returns
Promise<boolean>
A promise that resolves to true if the contract method was successful
Defined in
src/treasurypools/index.ts:197
exerciseOption
exerciseOption(web3, address, option, cashClose?): Promise<Transaction>
Excercises the option
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
web3 | default | undefined | The Web3 object |
address | string | undefined | The users selected account address from their wallet |
option | Option | undefined | The option to excercise |
cashClose | boolean | false | Return the payment currency instead of the underlying asset |
Returns
Promise<Transaction>
A promise that resolves to the completed transaction
Defined in
src/treasurypools/index.ts:246
findBestAMM
findBestAMM(web3, type, network, assetAddress, paymentAddress): Promise<MarketMaker>
Returns the best market maker
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The Web3 object |
type | string | The option type |
network | Network | The network |
assetAddress | string | Asset currency address |
paymentAddress | string | Payment currency address |
Returns
Promise<MarketMaker>
A promise that resolves to a MarketMaker
Defined in
src/treasurypools/index.ts:358
getAMMExchangeRate
getAMMExchangeRate(web3, option): Promise<BigNumber>
Get automated market maker exchange rate, calls relevant smart contract to return exchange rate
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
option | Option | The option |
Returns
Promise<BigNumber>
Returns the estimated rate
Defined in
src/treasurypools/index.ts:300
getBalance
getBalance(web3, address, decimals?, erc20Address?): Promise<BigNumber>
Gets the balance of the users selected account from the web3 wallet
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
web3 | default | undefined | The web3 object |
address | string | undefined | The users selected account address from their wallet |
decimals | number | 18 | currency decimals (defaults to 18) |
erc20Address? | string | undefined | The ERC20 address (if applicable) |
Returns
Promise<BigNumber>
The balance of the users selected account
Defined in
getERC20ContractInfo
getERC20ContractInfo(web3, erc20Address): Promise<TokenInformation>
Returns token information for the ERC20 token
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The Web3 object |
erc20Address | string | The ERC20 token address to query |
Returns
Promise<TokenInformation>
A promise that resolves to the token information object
Defined in
src/treasurypools/index.ts:323
hasApprovals
hasApprovals(web3, address, hedgeyAddress, erc20Address, approvalAmount?): Promise<boolean>
Checks if hedgey is approved to spend from the selected account on behalf of the user
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
hedgeyAddress | string | The hedgey contract address |
erc20Address | string | The erc20 The currency address |
approvalAmount? | string | - |
Returns
Promise<boolean>
A boolean value, true if the address has approval
Defined in
launchNewPair
launchNewPair(web3, address, factoryAddress, assetAddress, paymentAddress): Promise<Transaction>
Creates a new currency pair
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The Web3 object |
address | string | The users selected account address from their wallet |
factoryAddress | string | The factory address |
assetAddress | string | Asset currency address |
paymentAddress | string | Payment currency address |
Returns
Promise<Transaction>
A promise that resolves to the completed transaction
Defined in
src/treasurypools/index.ts:433
returnExpired
returnExpired(web3, address, option, indices): Promise<Transaction>
Returns the expired tokens to the user wallet
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The Web3 object |
address | string | The users selected account address from their wallet |
option | Option | The expired option |
indices | number[] | The indices of the options to return |
Returns
Promise<Transaction>
A promise that resolves to the completed transaction
Defined in
src/treasurypools/index.ts:284
setPrice
setPrice(web3, address, option, newPrice, tradeable?): Promise<any>
Sets the price on an open option
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
web3 | default | undefined | The Web3 object |
address | string | undefined | The users selected account address from their wallet |
option | Option | undefined | The option to set the price on |
newPrice | number | undefined | The new price |
tradeable | boolean | true | If the option is tradeable, defaults to true |
Returns
Promise<any>
A promise that resolves to true if the contract method was successful
Defined in
src/treasurypools/index.ts:224
switchChain
switchChain(network): Promise<boolean>
Swtich chain to a new network
Parameters
| Name | Type | Description |
|---|---|---|
network | Network | The network to switch to |
Returns
Promise<boolean>
A promise that resolves to true on a successful switch
Defined in
src/treasurypools/index.ts:461
writeOption
writeOption(web3, address, pair, option): Promise<Transaction>
Calls the relevant hedgey smart contract to create a new option
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
address | string | The users selected account address from their wallet |
pair | Pair | The currency pair |
option | Option | The option to create |
Returns
Promise<Transaction>
A promise that resolves to the completed transaction
Defined in
src/treasurypools/index.ts:154
Hedgey common
addTokenToWallet
addTokenToWallet(web3, network): Promise<any>
Prompts the user to add the network base token to their wallet
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
network | Network | The network |
Returns
Promise<any>
The transaction promise
Defined in
estimateGas
estimateGas(web3, contract, from, method, params, value?): Promise<{ gasEstimation: null | number ; gasPrice: null | string }>
Estimates the cost of gas
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
web3 | default | undefined | The web3 object |
contract | Contract | undefined | The contract |
from | string | undefined | The address sending the transaction |
method | string | undefined | The method of the contract to call |
params | any[] | undefined | The parameters that will be sent to the contract method |
value | string | '0' | If any tokens are being sent |
Returns
Promise<{ gasEstimation: null | number ; gasPrice: null | string }>
The gas price and gas estimation amount
Defined in
wrapTokens
wrapTokens(web3, assetAmount, wrappedTokenAddress, address): Promise<TransactionReceipt>
Will wrap the network token
Parameters
| Name | Type | Description |
|---|---|---|
web3 | default | The web3 object |
assetAmount | string | The amount to wrap |
wrappedTokenAddress | string | The wrapped token contract address |
address | string | The users wallet address |
Returns
Promise<TransactionReceipt>
The transaction promise
Defined in
9 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago