UNPKG

@firefly-exchange/library-sui

Version:

Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui

279 lines (278 loc) 16.8 kB
import { SuiClient, SuiTransactionBlockResponse } from "@mysten/sui/client"; import { Signer } from "@mysten/sui/cryptography"; import { Transaction as TransactionBlock } from "@mysten/sui/transactions"; import BigNumber from "bignumber.js"; import { DecodeJWT, ZkPayload } from "../interfaces"; import { BigNumberable, PartialZkLoginSignature } from "../types"; import { BLVDeploymentConfig, RewardPool, User } from "./interface"; import { VaultType } from "./enums"; import { SignaturePayloadStruct } from "./signer"; import { NumStr } from "../types"; export declare class Interactor { suiClient: SuiClient; signer: Signer; deployment: BLVDeploymentConfig; isWalletExtension: boolean; isZKLogin: boolean; maxEpoch?: number; proof?: PartialZkLoginSignature; decodedJWT?: DecodeJWT; salt?: string; walletAddress?: string; poolIdToCoin: { [key: string]: string; }; constructor(_suiClient: SuiClient, _deployment: any, _signer?: Signer, isWalletExtension?: boolean, _isZKLogin?: boolean, zkPayload?: ZkPayload, _walletAddress?: string); signAndExecuteTxBlock(transactionBlock: TransactionBlock, signer?: Signer): Promise<SuiTransactionBlockResponse>; private executeWalletTransaction; private executeTxBlock; private executeZkTransaction; getZkPayload: () => ZkPayload; private postCall; /** * Allows the caller to create the vault * @param vaultName name of the vault (the market maker) for which the vault is being created * @param operator the address of the trading account that will trade using vaults funds * @param holdingAccount the address of mm's holding account that can receive profits from the vault * @param claimsManager the address of account that can generate funds claim signature * @param maxCapacity max amount that can be locked in the vault * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ createVault(vaultName: string, operator: string, holdingAccount: string, claimsManager: string, maxCapacity: BigNumberable, vaultType: VaultType, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows the caller to create a non-trading vault * @param vaultName name of the vault (the market maker) for which the vault is being created * @param claimsManager the address of account that can generate funds claim signature * @param maxCapacity max amount that can be locked in the vault - This should be in 1eX format. Where `X` being the decimals supported by the vault coin * @param supportedCoinType the supported coin of the vault * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ createNonTradingVault(vaultName: string, claimsManager: string, maxCapacity: BigNumberable, supportedCoin: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows admin of the protocol to create reward pools * @param rewardCoin The reward coin that will be funded into the pool and then claimed by users * @param controller The operator that will be creating reward signatures * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ createRewardPool(rewardCoin: string, controller?: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows the caller to fund a rewards pool * @param pool the reward pool to which the amount will be deposited * @param amount the amount to be deposited into the pool (must be in base number, the method adds 9 decimal places) * @returns SuiTransactionBlockResponse */ fundRewardPool(pool: RewardPool, amount: BigNumberable): Promise<SuiTransactionBlockResponse>; /** * Allows caller to change the admin of the vault store * The caller must be the admin of provided vault store * @param newAdmin address of new vault store admin * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ setVaultStoreAdmin(newAdmin: string, multiSig?: string): Promise<string | SuiTransactionBlockResponse>; /** * Allows caller to set the vault bank manager on the bluefin vault store * The caller must be the admin of provided vault store * @param manager address of new bank manager * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ setVaultBankManager(manager: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows caller to set the vault claims manager for the provided vault * @param vaultName the name of the vault for which to update the manager * @param manager address of new claims manager * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ setVaultClaimsManager(vaultName: string, manager: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows caller to set the vault bank manager on the bluefin vault store * The caller must be the admin of provided vault store * @param manager address of new bank manager * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ setVaultOperator(vaultName: string, operator: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows caller to set the admin of vault store * The caller must be the admin of provided vault store * @param admin address of new admin * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ setAdmin(admin: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows caller to set the controller of a reward pool * The caller must be the admin of package * @param controller address of new controller * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ setController(pool: string, controller: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows caller to mark the provided nonce as claimed on-chain, effectively invalidating the * signature created using that nonce. * @param pool The name of the pool * @param nonce the nonce to be marked as claimed * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ markNonceAsClaimed(pool: string, nonce: NumStr, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Returns the balance of the pool */ getPoolBalance(pool: string): Promise<BigNumber>; /** * Allows caller to pause a vault * The caller must be the admin of provided vault store * @param vaultName name of the vault(Nexus etc..) * @param pause boolean value to pause/unpause the vault * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ pauseVault(vaultName: string, pauseDeposit: boolean, pauseWithdraw: boolean, pauseClaim: boolean, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows caller(holding account of vault) to request profit withdraw from vault * @param vaultName name of the vault(Nexus etc..) * @param amount the amount of profit to withdraw * @returns SuiTransactionBlockResponse or transaction bytes */ requestProfitWithdraw(vaultName: string, amount: BigNumberable): Promise<SuiTransactionBlockResponse>; /** * Allows users to deposit funds into a vault * @param vaultName name of the vault(Nexus etc..) * @param amount the amount of tokens to deposit - should be in base number with NO EXTRA DECIMALS * @param options optional arguments * - receiver: the address of the user that will receive deposited amount rewards on elixir * @returns SuiTransactionBlockResponse or transaction bytes */ depositToVault(vaultName: string, amount: BigNumberable, options?: { receiver?: string; }): Promise<SuiTransactionBlockResponse>; /** * Allows caller to move funds the bank account of a vault inside bluefin's margin bank * into the vault to hold for people to come in and withdraw * @param vaultName The name of the vault * @param amount The amount of funds to be moved */ moveWithdrawalFundsToVault(vaultName: string, amount: BigNumberable): Promise<SuiTransactionBlockResponse>; /** * Allows caller to move profit amount from the bank account of a vault inside bluefin's margin bank * to vault's holding account. * @param vaultName The name of the vault * @param amount The amount of funds to be moved */ moveProfitWithdrawalFundsToHoldingAccount(vaultName: string, amount: BigNumberable): Promise<SuiTransactionBlockResponse>; /** * Allows caller to request withdraw their locked funds from provided vault * @param vaultName the name of the vault (partner name) * @param amount the amount of tokens to deposit - should be in base number with NO EXTRA DECIMALS * @returns SuiTransactionBlockResponse or transaction bytes */ requestWithdrawFromVault(vaultName: string, amount: BigNumberable): Promise<SuiTransactionBlockResponse>; /** * Allows caller to claim withdrawn funds on a user's behalf * @param vaultName the name of the vault from which funds are to be claimed * @param payload The signature payload consisting of * - target The address of reward pool from which to claim rewards * - receiver The address for which to claim rewards * - amount The amount of rewards to be claimed (Must be in 1e9 Format that the signer signed on) * - nonce The unique nonce used by pool's operator to generate signature * - type The type of signature payload (RewardsClaim | FundsClaim) * @param signature The signature created by pool's operator for provided payload */ claimFunds(vaultName: string, payload: typeof SignaturePayloadStruct.$inferType, signature: string): Promise<SuiTransactionBlockResponse>; /** * Allows caller to batch claim * Input is array of * @param batch * payload: The signature payload consisting of * - target The address of reward pool from which to claim rewards * - receiver The address for which to claim rewards * - amount The amount of rewards to be claimed (Must be in 1e9 Format that the signer signed on) * - nonce The unique nonce used by pool's operator to generate signature * - type The type of signature payload (RewardsClaim | FundsClaim) * signature: The signature created by pool's operator for provided payload */ claimFundsBatch(batch: { vaultName: string; payload: typeof SignaturePayloadStruct.$inferType; signature: string; }[]): Promise<SuiTransactionBlockResponse>; /** * Allows caller to claim rewards for the provided receiver from provided rewards pool * @param payload The signature payload consisting of * - target The address of reward pool from which to claim rewards * - receiver The address for which to claim rewards * - amount The amount of rewards to be claimed (Must be in 1e9 Format that the signer signed on) * - nonce The unique nonce used by pool's operator to generate signature * - type The type of signature payload (RewardsClaim | FundsClaim) * @param signature The signature created by pool's operator for provided payload */ claimRewards(poolName: string, payload: typeof SignaturePayloadStruct.$inferType, signature: string): Promise<SuiTransactionBlockResponse>; /** * Allows caller to claim rewards for the provided receiver from provided rewards pool * @param batch consisting of * payload: The signature payload consisting of * - target The address of reward pool from which to claim rewards * - receiver The address for which to claim rewards * - amount The amount of rewards to be claimed (Must be in 1e9 Format that the signer signed on) * - nonce The unique nonce used by pool's operator to generate signature * - type The type of signature payload (RewardsClaim | FundsClaim) * signature: The signature created by pool's operator for provided payload */ claimRewardsBatch(batch: { payload: typeof SignaturePayloadStruct.$inferType; signature: string; }[]): Promise<SuiTransactionBlockResponse>; /** * Allows admin to update vault version * @param vaultName the name of the vault * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ updateVaultVersion(vaultName: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows admin to update rewards pool version * @param poolName the name of the rewards pool * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ updateRewardsPoolVersion(poolName: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows holder of the admin cap to transfer it to new user * @param newAdmin the address of new admin * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ transferAdminCap(newAdmin: string, multiSig?: string): Promise<SuiTransactionBlockResponse | string>; /** * Allows admin to move locked funds from one vault to another * @param srcVault the name of source vault * @param destVault the name of destination vault * @param accounts the addresses of accounts that will be moved * @param multiSig optional multisig wallet address. if provided the method will return tx bytes of the tx instead of executing it * @returns SuiTransactionBlockResponse or transaction bytes */ moveFundsAcrossVaults(srcVault: string, destVault: string, accounts: string[], multiSig?: string): Promise<SuiTransactionBlockResponse | string>; getVaultTVLProviders(vaultName: string): Promise<string[]>; getUserRecordForVault(vaultName: string, user?: string): Promise<User>; getUserLockedAmount(vaultName: string, user?: string): Promise<number>; getUserPendingWithdrawals(vaultName: string, user?: string): Promise<number>; getTotalPendingWithdrawalAmount(vaultName: string): Promise<number>; getVaultLockedAmount(vaultName: string): Promise<number>; getVaultCoinBalance(vaultName: string): Promise<number>; getBluefinBankBalance(address?: string): Promise<number>; getCoinBalance(coinType: string, coinDecimals: number, address?: string): Promise<number>; getSupportedCoin(): string; getVaultCoin(vaultName: string): string; getVaultID(vaultName: string): string; getVaultType(vaultName: string): VaultType; getVaultAccount(vaultName: string): string; getVaultDecimals(vaultName: string): number; getRewardsPool(poolName: string): RewardPool; }