@superfluid-finance/sdk-core
Version:
SDK Core for building with Superfluid Protocol
566 lines • 28.1 kB
TypeScript
import { BytesLike, ethers, Overrides } from "ethers";
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
import ERC20Token from "./ERC20Token";
import GeneralDistributionAgreementV1 from "./GeneralDistributionAgreementV1";
import Governance from "./Governance";
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
import Operation from "./Operation";
import { ConnectPoolParams, DisconnectPoolParams, ERC20DecreaseAllowanceParams, ERC20IncreaseAllowanceParams, ERC777SendParams, FlowDistributionActualFlowRateData, GetPoolAdjustmentFlowInfoParams, IConfig, IRealtimeBalanceOfParams, IsMemberConnectedParams, ISuperTokenBaseIDAParams, ISuperTokenCreateFlowByOperatorParams, ISuperTokenCreateFlowParams, ISuperTokenDeleteFlowParams, ISuperTokenDistributeParams, ISuperTokenFlowOperatorDataByIDParams, ISuperTokenFlowOperatorDataParams, ISuperTokenFullControlParams, ISuperTokenGetFlowInfoParams, ISuperTokenGetFlowParams, ISuperTokenGetIndexParams, ISuperTokenGetSubscriptionParams, ISuperTokenPublisherOperationParams, ISuperTokenPubSubParams, ISuperTokenUpdateFlowByOperatorParams, ISuperTokenUpdateFlowOperatorPermissionsParams, ISuperTokenUpdateFlowParams, ISuperTokenUpdateIndexValueParams, ISuperTokenUpdateSubscriptionUnitsParams, IWeb3FlowInfo, IWeb3FlowOperatorData, IWeb3GovernanceParams, IWeb3Index, IWeb3RealTimeBalanceOf, IWeb3Subscription, SuperTokenCreatePoolParams, SuperTokenDistributeFlowParams, SuperTokenDistributeParams, SuperTokenEstimateDistributionActualAmountParams, SuperTokenEstimateDistributionActualFlowRateParams, SuperTokenFlowRateAllowanceParams, SuperTokenFlowRateAllowanceWithPermissionsParams, SuperTokenGDAGetFlowRateParams, SuperTokenGDAGetNetFlowParams, SuperTokenGetPoolAdjustmentFlowRateParams, SuperTokenIsPoolParams } from "./interfaces";
import { ISETH, ISuperToken } from "./typechain-types";
export interface ITokenSettings {
readonly address: string;
readonly config: IConfig;
readonly chainId: number;
readonly networkName: string;
}
export interface ITokenOptions {
readonly address: string;
readonly config: IConfig;
readonly provider: ethers.providers.Provider;
readonly chainId?: number;
readonly networkName?: string;
}
/**
* SuperToken Helper Class
* @description A helper class to create `SuperToken` objects which can interact with the `SuperToken` contract as well as the CFAV1 and IDAV1 contracts of the desired `SuperToken`.
* @see https://www.notion.so/superfluidhq/Classification-of-Super-Tokens-5beace780b5c4d09a5752a3677da3dc0 for further details on naming classification and underlying implementation.
*/
export default abstract class SuperToken extends ERC20Token {
readonly options: ITokenOptions;
readonly settings: ITokenSettings;
readonly cfaV1: ConstantFlowAgreementV1;
readonly idaV1: InstantDistributionAgreementV1;
readonly gdaV1: GeneralDistributionAgreementV1;
readonly governance: Governance;
readonly underlyingToken?: ERC20Token;
readonly contract: ISuperToken;
protected constructor(options: ITokenOptions, settings: ITokenSettings);
static create: (options: ITokenOptions) => Promise<SuperToken>;
/** ### ERC777 Token Write Functions ### */
/**
* Send `amount` tokens to `recipient` from transaction signer.
* @param recipient the recipient of the tokens
* @param amount the amount of tokens to send
* @param userData Extra user data provided.
*/
send: (params: ERC777SendParams) => Operation;
/** ### SuperToken Contract Read Functions ### */
/**
* Returns the real time balance of `address`.
* @param account the target address
* @param timestamp the timestamp you'd like to see the data
* @param providerOrSigner a provider or signer for executing a web3 call
* @returns {Promise<IWeb3RealTimeBalanceOf>} real time balance of data
*/
realtimeBalanceOf: ({ providerOrSigner, account, timestamp, }: IRealtimeBalanceOfParams) => Promise<IWeb3RealTimeBalanceOf>;
/** ### CFA Read Functions ### */
/**
* Get the details of a flow.
* @param sender the sender of the flow
* @param receiver the receiver of the flow
* @param providerOrSigner a provider or signer object
* @returns {Promise<IWeb3FlowInfo>} Web3 Flow info object
*/
getFlow: (params: ISuperTokenGetFlowParams) => Promise<IWeb3FlowInfo>;
/**
* Get the flow info of an account (net flow).
* @param account the account we're querying
* @param providerOrSigner a provider or signer object
* @returns {Promise<IWeb3FlowInfo>} Web3 Flow info object
*/
getAccountFlowInfo: (params: ISuperTokenGetFlowInfoParams) => Promise<IWeb3FlowInfo>;
/**
* Get the net flow of an account.
* @param account the account we're querying
* @param providerOrSigner a provider or signer object
* @returns {Promise<string>} Web3 Flow info object
*/
getNetFlow: (params: ISuperTokenGetFlowInfoParams) => Promise<string>;
/**
* Get flow operator data.
* @param sender the sender
* @param flowOperator the flowOperator
* @param providerOrSigner a provider or signer object
* @returns {Promise<IWeb3FlowOperatorData>} Web3 Flow info object
*/
getFlowOperatorData: (params: ISuperTokenFlowOperatorDataParams) => Promise<IWeb3FlowOperatorData>;
/**
* Get flow operator data using the flowOperatorId.
* @param flowOperatorId The keccak256 hash of encoded string "flowOperator", sender and flowOperator
* @param providerOrSigner a provider or signer object
* @returns {Promise<IWeb3FlowOperatorData>} Web3 Flow info object
*/
getFlowOperatorDataByID: (params: ISuperTokenFlowOperatorDataByIDParams) => Promise<IWeb3FlowOperatorData>;
/** ### ERC20 Write Functions ### */
/**
* Increases the allowance of `spender` by `amount`.
* @param spender the spender
* @param amount the amount to increase the allowance by
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
increaseAllowance: (params: ERC20IncreaseAllowanceParams) => Operation;
/**
* Decreases the allowance of `spender` by `amount`.
* @param spender the spender
* @param amount the amount to decrease the allowance by
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
decreaseAllowance: (params: ERC20DecreaseAllowanceParams) => Operation;
/** ### CFA Write Functions ### */
/**
* Create a flow of the token of this class.
* @param receiver The receiver of the flow.
* @param flowRate The specified flow rate.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
createFlow: (params: ISuperTokenCreateFlowParams) => Operation;
/**
* Update a flow of the token of this class.
* @param receiver The receiver of the flow.
* @param flowRate The specified flow rate.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
updateFlow: (params: ISuperTokenUpdateFlowParams) => Operation;
/**
* Delete a flow of the token of this class.
* @param sender The sender of the flow.
* @param receiver The receiver of the flow.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
deleteFlow: (params: ISuperTokenDeleteFlowParams) => Operation;
/** ### CFA ACL Write Functions (byOperator) ### */
/**
* Increase the flow rate allowance for an ACL operator.
* @param flowOperator The operator of the flow.
* @param flowRateAllowanceDelta The amount to increase the flow rate allowance by.
* @param userData Extra user data provided.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
increaseFlowRateAllowance(params: SuperTokenFlowRateAllowanceParams): Operation;
/**
* Decrease the flow rate allowance for an ACL operator.
* @param flowOperator The operator of the flow.
* @param flowRateAllowanceDelta The amount to decrease the flow rate allowance by.
* @param userData Extra user data provided.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
decreaseFlowRateAllowance(params: SuperTokenFlowRateAllowanceParams): Operation;
/**
* Increase the flow rate allowance and sets permissions for an ACL operator.
* @param flowOperator The permission grantee address
* @param permission The permissions to set.
* @param flowRateAllowance The amount to increase the flow rate allowance by.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
*
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
increaseFlowRateAllowanceWithPermissions(params: SuperTokenFlowRateAllowanceWithPermissionsParams): Operation;
/**
* Decrease the flow rate allowance and sets permissions for an ACL operator.
* @param flowOperator The permission grantee address
* @param permission The permissions to set.
* @param flowRateAllowance The amount to decrease the flow rate allowance by.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
*
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
decreaseFlowRateAllowanceWithPermissions(params: SuperTokenFlowRateAllowanceWithPermissionsParams): Operation;
/**
* Update permissions for a flow operator as a sender.
* @param flowOperator The permission grantee address
* @param permission The permissions to set.
* @param flowRateAllowance The flowRateAllowance granted to the flow operator.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
updateFlowOperatorPermissions(params: ISuperTokenUpdateFlowOperatorPermissionsParams): Operation;
/**
* Give flow operator full control - max flow rate and create/update/delete permissions.
* @param flowOperator The permission grantee address
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
*/
authorizeFlowOperatorWithFullControl(params: ISuperTokenFullControlParams): Operation;
/**
* Revoke flow operator control - set flow rate to 0 with no permissions.
* @param flowOperator The permission grantee address
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
*/
revokeFlowOperatorWithFullControl(params: ISuperTokenFullControlParams): Operation;
/**
* Create a flow as an operator
* @param flowRate The specified flow rate.
* @param sender The sender of the flow.
* @param receiver The receiver of the flow.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
createFlowByOperator: (params: ISuperTokenCreateFlowByOperatorParams) => Operation;
/**
* Update a flow as an operator.
* @param flowRate The specified flow rate.
* @param sender The sender of the flow.
* @param receiver The receiver of the flow.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
updateFlowByOperator: (params: ISuperTokenUpdateFlowByOperatorParams) => Operation;
/**
* Delete a flow as an operator.
* @param sender The sender of the flow.
* @param receiver The receiver of the flow.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
deleteFlowByOperator: (params: ISuperTokenDeleteFlowParams) => Operation;
/** ### IDA Read Functions ### */
/**
* Get the details of a `Subscription`.
* @param publisher the address of the publisher of the index
* @param indexId the index id
* @param subscriber the subscriber's address
* @param providerOrSigner a provider or signer object
* @returns {Promise<IWeb3Subscription>} Web3 Subscription object
*/
getSubscription: (params: ISuperTokenGetSubscriptionParams) => Promise<IWeb3Subscription>;
/**
* Get the details of an `Index`.
* @param publisher the address of the publisher of the index
* @param indexId the index id
* @param providerOrSigner a provider or signer object
* @returns {Promise<IWeb3Index>} Web3 Index object
*/
getIndex: (params: ISuperTokenGetIndexParams) => Promise<IWeb3Index>;
/** ### IDA Write Functions ### */
/**
* Creates an IDA Index.
* @param indexId The id of the index.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
createIndex: (params: ISuperTokenBaseIDAParams) => Operation;
/**
* Distributes `amount` of token to an index
* @param indexId The id of the index.
* @param amount The amount of tokens to be distributed.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
distribute: (params: ISuperTokenDistributeParams) => Operation;
/**
* Updates the `IndexValue` field of an index.
* @param indexId The id of the index.
* @param indexValue The new indexValue.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*
* NOTE: It has the same effect as `distribute`, but is closer to the low level data structure of the index.
*/
updateIndexValue: (params: ISuperTokenUpdateIndexValueParams) => Operation;
/**
* Updates the `units` allocated to a Subscription.
* @param indexId The id of the index.
* @param subscriber The subscriber address whose units you want to update.
* @param units The amount of units you want to update to.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
updateSubscriptionUnits: (params: ISuperTokenUpdateSubscriptionUnitsParams) => Operation;
/**
* Approves a Subscription, so the Subscriber won't need to claim tokens when the Publisher distributes.
* @param indexId The id of the index.
* @param publisher The publisher address whose subscription you want to approve.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
approveSubscription: (params: ISuperTokenPublisherOperationParams) => Operation;
/**
* Revokes a Subscription, so the Subscriber will need to claim tokens when the Publisher distributes.
* @param indexId The id of the index.
* @param publisher The index publisher address you want to revoke for the subscriber.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
revokeSubscription: (params: ISuperTokenPublisherOperationParams) => Operation;
/**
* Deletes a Subscription by setting the `units` allocated to the Subscriber to 0.
* @param indexId The id of the index.
* @param subscriber The subscriber address whose subscription you want to delete.
* @param publisher The publisher address of the index you are targeting.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
deleteSubscription: (params: ISuperTokenPubSubParams) => Operation;
/**
* Claims any pending tokens allocated to the Subscription (unapproved).
* @param indexId The id of the index.
* @param subscriber The subscriber address who you are claiming for.
* @param publisher The publisher address of the index you are targeting.
* @param userData Extra user data provided.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
claim: (params: ISuperTokenPubSubParams) => Operation;
/** ### GDA Read Functions ### */
/**
* Retrieves the net flow for a specific token and account.
*
* @param account The account address.
* @param providerOrSigner A provider or signer object
* @returns The net flow of the account for the token.
*/
getGDANetFlow: (params: SuperTokenGDAGetNetFlowParams) => Promise<string>;
/**
* Retrieves the flow rate for a specific token, sender, and pool.
*
* @param from The sender address.
* @param pool The pool address.
* @param providerOrSigner A provider or signer object
* @returns The flow rate from the sender to the pool for the token.
*/
getFlowRate: (params: SuperTokenGDAGetFlowRateParams) => Promise<string>;
/**
* Estimates the flow distribution's actual flow rate for a specific token, sender, and pool.
*
* @param from The sender address.
* @param pool The pool address.
* @param requestedFlowRate The requested flow rate.
* @param providerOrSigner A provider or signer object
* @returns The flow distribution's actual flow rate and the total distribution flow rate for the pool.
*/
estimateFlowDistributionActualFlowRate: (params: SuperTokenEstimateDistributionActualFlowRateParams) => Promise<FlowDistributionActualFlowRateData>;
/**
* Estimates the distribution's actual amount for a specific token, sender, and pool.
*
* @param from The sender address.
* @param pool The pool address.
* @param requestedAmount The requested amount.
* @param providerOrSigner A provider or signer object
* @returns The actual amount that will be distributed.
*/
estimateDistributionActualAmount: (params: SuperTokenEstimateDistributionActualAmountParams) => Promise<string>;
/**
* Retrieves the pool adjustment flow rate for a specific token and pool.
*
* @param pool The pool address.
* @param providerOrSigner A provider or signer object
* @returns The pool adjustment flow rate for the token and pool.
*/
getPoolAdjustmentFlowRate: (params: SuperTokenGetPoolAdjustmentFlowRateParams) => Promise<string>;
/**
* Checks if a given token and account form a pool.
*
* @param account The account address.
* @param providerOrSigner A provider or signer object
* @returns Whether the account is a pool for the token.
*/
isPool: (params: SuperTokenIsPoolParams) => Promise<boolean>;
/**
* Checks if a member is connected to a specific pool.
*
* @param pool The pool address.
* @param member The member address.
* @param providerOrSigner A provider or signer object
* @returns Whether the member is connected to the pool.
*/
isMemberConnected: (params: IsMemberConnectedParams) => Promise<boolean>;
/**
* Retrieves the pool adjustment flow information for a specific pool.
*
* @param poolAddress The address of the pool.
* @param providerOrSigner A provider or signer object
* @returns The recipient of the pool adjustment flow, the flow hash and the rate of the adjustment flow.
*/
getPoolAdjustmentFlowInfo: (params: GetPoolAdjustmentFlowInfoParams) => Promise<import("./interfaces").PoolAdjustmentFlowInfo>;
/** ### GDA Write Functions ### */
/**
* Creates a new pool with the given token and admin.
*
* @param admin The admin address.
* @param overrides The transaction overrides.
* @returns The contract transaction and the pool address
*/
createPool: (params: SuperTokenCreatePoolParams) => Promise<{
createPoolTxn: ethers.ContractTransaction;
pool: import("./SuperfluidPool").default;
}>;
/**
* Connects a pool to the contract.
*
* @param pool The pool address.
* @param userData The user data.
* @param overrides The transaction overrides.
* @returns The call agreement operation result.
*/
connectPool: (params: ConnectPoolParams) => Operation;
/**
* Disconnects a pool from the contract.
*
* @param pool The pool address.
* @param userData The user data.
* @param overrides The transaction overrides.
* @returns The call agreement operation result.
*/
disconnectPool: (params: DisconnectPoolParams) => Operation;
/**
* Distributes funds from the sender's account to the specified pool.
*
* @param from The sender's address.
* @param pool The pool address.
* @param requestedAmount The requested amount to distribute.
* @param userData The user data.
* @param overrides The transaction overrides.
* @returns The call agreement operation result.
*/
distributeWithGDA: (params: SuperTokenDistributeParams) => Operation;
/**
* Distributes the flow from the sender's account to the specified pool.
*
* @param from The sender's address.
* @param pool The pool address.
* @param requestedFlowRate The requested flow rate.
* @param userData The user data.
* @param overrides The transaction overrides.
* @returns The call agreement operation result.
*/
distributeFlow: (params: SuperTokenDistributeFlowParams) => Operation;
/** ### Governance Read Functions ### */
getGovernanceParameters: (providerOrSigner: ethers.providers.Provider | ethers.Signer) => Promise<IWeb3GovernanceParams>;
}
/**
* WrapperSuperToken has an underlying ERC20 token.
*/
export declare class WrapperSuperToken extends SuperToken {
readonly underlyingToken: ERC20Token;
constructor(options: ITokenOptions, settings: ITokenSettings & {
underlyingTokenAddress: string;
});
/** ### WrapperSuperToken Contract Write Functions ### */
/**
* Downgrade `amount` SuperToken's.
* @param amount The amount to be downgraded.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
downgrade: ({ amount, overrides, }: {
amount: string;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
/**
* Downgrade `amount` of an ERC20 token to its SuperToken to `to` address.
* @param amount The amount to be downgraded.
* @param to The destination of the downgraded ERC20 token.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed.
*/
downgradeTo: ({ amount, to, overrides, }: {
amount: string;
to: string;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
/**
* Upgrade `amount` SuperToken's.
* @param amount The amount to be upgraded.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed or batched.
*/
upgrade: ({ amount, overrides, }: {
amount: string;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
/**
* Upgrade `amount` of an ERC20 token to its SuperToken to `to` address.
* @param amount The amount to be upgraded.
* @param to The destination of the upgraded wrapper super tokens.
* @param data Bytes userData
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed.
*/
upgradeTo: ({ amount, to, data, overrides, }: {
amount: string;
to: string;
data?: BytesLike;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
}
/**
* PureSuperToken doesn't have any underlying ERC20 token.
*/
export declare class PureSuperToken extends SuperToken {
constructor(options: ITokenOptions, settings: ITokenSettings);
}
/**
* NativeAssetSuperToken wraps the native asset of the network.
*/
export declare class NativeAssetSuperToken extends SuperToken {
readonly nativeTokenSymbol: string;
constructor(options: ITokenOptions, settings: ITokenSettings, nativeTokenSymbol: string);
get nativeAssetContract(): ISETH;
/**
* Upgrade `amount` of a network's native asset to its SuperToken.
* @param amount The amount to be upgraded.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed.
*/
upgrade: ({ amount, overrides, }: {
amount: string;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
/**
* Upgrade `amount` of a network's native asset to its SuperToken to `to` address.
* @param amount The amount to be upgraded.
* @param to The destination of the upgraded native asset super tokens.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed.
*/
upgradeTo: ({ amount, to, overrides, }: {
amount: string;
to: string;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
/**
* Downgrade `amount` of a native asset super token to the underlying native asset.
* @param amount The amount to be upgraded.
* @param overrides ethers overrides object for more control over the transaction sent.
* @returns {Operation} An instance of Operation which can be executed.
*/
downgrade: ({ amount, overrides, }: {
amount: string;
overrides?: Overrides & {
from?: string;
};
}) => Operation;
}
//# sourceMappingURL=SuperToken.d.ts.map