@0xknwn/starknet-test-helpers / Exports / SwapRouter
Class: SwapRouter
Represents a Swap contract.
Hierarchy
-
Contract
↳
SwapRouter
Table of contents
Constructors
Properties
- abi
- address
- callStatic
- deployTransactionHash
- estimateFee
- events
- functions
- populateTransaction
- providerOrAccount
- structs
Methods
- attach
- call
- connect
- deployed
- estimate
- faucet
- getVersion
- get_conversion_rate
- invoke
- isCairo1
- parseEvents
- populate
- set_conversion_rate
- set_tokens
- swap
- swap_maximum_at
- swap_minimum_at
- typedv2
Constructors
constructor
• new SwapRouter(address
, account
): SwapRouter
Creates an instance of the Counter contract.
Parameters
Name | Type | Description |
---|---|---|
address | string | The address of the contract. |
account | Account | The account used to interact with the contract. |
Returns
Overrides
Contract.constructor
Defined in
sdks/tests/helpers/src/swap_router.ts:55
Properties
abi
• abi: Abi
Inherited from
Contract.abi
Defined in
node_modules/starknet/dist/index.d.ts:3957
address
• address: string
Inherited from
Contract.address
Defined in
node_modules/starknet/dist/index.d.ts:3958
callStatic
• Readonly
callStatic: Object
Index signature
▪ [name: string
]: AsyncContractFunction
Inherited from
Contract.callStatic
Defined in
node_modules/starknet/dist/index.d.ts:3968
deployTransactionHash
• Optional
deployTransactionHash: string
Inherited from
Contract.deployTransactionHash
Defined in
node_modules/starknet/dist/index.d.ts:3960
estimateFee
• Readonly
estimateFee: Object
Index signature
▪ [name: string
]: ContractFunction
Inherited from
Contract.estimateFee
Defined in
node_modules/starknet/dist/index.d.ts:3974
events
• Protected
Readonly
events: AbiEvents
Inherited from
Contract.events
Defined in
node_modules/starknet/dist/index.d.ts:3964
functions
• Readonly
functions: Object
Index signature
▪ [name: string
]: AsyncContractFunction
Inherited from
Contract.functions
Defined in
node_modules/starknet/dist/index.d.ts:3965
populateTransaction
• Readonly
populateTransaction: Object
Index signature
▪ [name: string
]: ContractFunction
Inherited from
Contract.populateTransaction
Defined in
node_modules/starknet/dist/index.d.ts:3971
providerOrAccount
• providerOrAccount: ProviderInterface
| AccountInterface
Inherited from
Contract.providerOrAccount
Defined in
node_modules/starknet/dist/index.d.ts:3959
structs
• Protected
Readonly
structs: Object
Index signature
▪ [name: string
]: StructAbi
Inherited from
Contract.structs
Defined in
node_modules/starknet/dist/index.d.ts:3961
Methods
attach
▸ attach(address
): void
Parameters
Name | Type |
---|---|
address | string |
Returns
void
Inherited from
Contract.attach
Defined in
node_modules/starknet/dist/index.d.ts:3987
call
▸ call(method
, args?
, «destructured»?
): Promise
<Result
>
Parameters
Name | Type |
---|---|
method | string |
args? | ArgsOrCalldata |
«destructured» | CallOptions |
Returns
Promise
<Result
>
Inherited from
Contract.call
Defined in
node_modules/starknet/dist/index.d.ts:3990
connect
▸ connect(providerOrAccount
): void
Parameters
Name | Type |
---|---|
providerOrAccount | ProviderInterface | AccountInterface |
Returns
void
Inherited from
Contract.connect
Defined in
node_modules/starknet/dist/index.d.ts:3988
deployed
▸ deployed(): Promise
<Contract
>
Returns
Promise
<Contract
>
Inherited from
Contract.deployed
Defined in
node_modules/starknet/dist/index.d.ts:3989
estimate
▸ estimate(method
, args?
): Promise
<EstimateFeeResponse
>
Parameters
Name | Type |
---|---|
method | string |
args? | ArgsOrCalldata |
Returns
Promise
<EstimateFeeResponse
>
Inherited from
Contract.estimate
Defined in
node_modules/starknet/dist/index.d.ts:3992
faucet
▸ faucet(amount
): Promise
<GetTransactionReceiptResponse
>
Sends a request to the faucet to receive a specified amount of Token A.
Parameters
Name | Type | Description |
---|---|---|
amount | Uint256 | The amount of tokens to request from the faucet. |
Returns
Promise
<GetTransactionReceiptResponse
>
A promise that resolves to the transaction receipt once the transfer is complete.
Defined in
sdks/tests/helpers/src/swap_router.ts:64
getVersion
▸ getVersion(): Promise
<ContractVersion
>
Returns
Promise
<ContractVersion
>
Inherited from
Contract.getVersion
Defined in
node_modules/starknet/dist/index.d.ts:3996
get_conversion_rate
▸ get_conversion_rate(): Promise
<bigint
>
Retrieves the conversion rate.
Returns
Promise
<bigint
>
A promise that resolves to a bigint representing the conversion rate.
Defined in
sdks/tests/helpers/src/swap_router.ts:108
invoke
▸ invoke(method
, args?
, «destructured»?
): Promise
<{ transaction_hash
: string
}>
Parameters
Name | Type |
---|---|
method | string |
args? | ArgsOrCalldata |
«destructured» | InvokeOptions |
Returns
Promise
<{ transaction_hash
: string
}>
Inherited from
Contract.invoke
Defined in
node_modules/starknet/dist/index.d.ts:3991
isCairo1
▸ isCairo1(): boolean
Returns
boolean
Inherited from
Contract.isCairo1
Defined in
node_modules/starknet/dist/index.d.ts:3995
parseEvents
▸ parseEvents(receipt
): ParsedEvents
Parameters
Name | Type |
---|---|
receipt | GetTransactionReceiptResponse |
Returns
ParsedEvents
Inherited from
Contract.parseEvents
Defined in
node_modules/starknet/dist/index.d.ts:3994
populate
▸ populate(method
, args?
): Call
Parameters
Name | Type |
---|---|
method | string |
args? | RawArgs |
Returns
Call
Inherited from
Contract.populate
Defined in
node_modules/starknet/dist/index.d.ts:3993
set_conversion_rate
▸ set_conversion_rate(rate
): Promise
<GetTransactionReceiptResponse
>
Sets the conversion rate for the swap router.
Parameters
Name | Type | Description |
---|---|---|
rate | string | The conversion rate to be set. |
Returns
Promise
<GetTransactionReceiptResponse
>
A promise that resolves to the transaction receipt once the conversion rate is set.
Defined in
sdks/tests/helpers/src/swap_router.ts:95
set_tokens
▸ set_tokens(tokenAAddress
, tokenBAddress
): Promise
<GetTransactionReceiptResponse
>
Sets the token addresses for tokenA and tokenB.
Parameters
Name | Type | Description |
---|---|---|
tokenAAddress | string | The address of tokenA. |
tokenBAddress | string | The address of tokenB. |
Returns
Promise
<GetTransactionReceiptResponse
>
A promise that resolves to the transaction receipt once the transaction is confirmed.
Defined in
sdks/tests/helpers/src/swap_router.ts:80
swap
▸ swap(tokenAAddress
, amount
): Promise
<GetTransactionReceiptResponse
>
Swaps a specified amount of a token for another token.
Parameters
Name | Type | Description |
---|---|---|
tokenAAddress | string | The address of the token to be swapped. |
amount | Uint256 | The amount of the token to be swapped. |
Returns
Promise
<GetTransactionReceiptResponse
>
A promise that resolves to the transaction receipt once the swap is completed.
Defined in
sdks/tests/helpers/src/swap_router.ts:118
swap_maximum_at
▸ swap_maximum_at(tokenAAddress
, rate
, amount
): Promise
<GetTransactionReceiptResponse
>
Swaps the maximum amount of tokens at a given rate.
Parameters
Name | Type | Description |
---|---|---|
tokenAAddress | string | The address of the token A. |
rate | string | The rate at which to swap the tokens. |
amount | Uint256 | The amount of tokens to swap. |
Returns
Promise
<GetTransactionReceiptResponse
>
A promise that resolves to the transaction receipt of the swap.
Defined in
sdks/tests/helpers/src/swap_router.ts:171
swap_minimum_at
▸ swap_minimum_at(tokenAAddress
, rate
, amount
): Promise
<GetTransactionReceiptResponse
>
Executes a swap with a minimum rate and amount.
Parameters
Name | Type | Description |
---|---|---|
tokenAAddress | string | The address of the token A. |
rate | string | The rate of the swap. |
amount | Uint256 | The amount to swap. |
Returns
Promise
<GetTransactionReceiptResponse
>
A promise that resolves to the transaction receipt of the swap.
Defined in
sdks/tests/helpers/src/swap_router.ts:145
typedv2
▸ typedv2<TAbi
>(tAbi
): TypedContractV2
<TAbi
>
Type parameters
Name | Type |
---|---|
TAbi | extends readonly (AbiImpl | AbiInterface | AbiConstructor | AbiFunction | AbiStruct | AbiEnum | AbiEvent )[] |
Parameters
Name | Type |
---|---|
tAbi | TAbi |
Returns
TypedContractV2
<TAbi
>
Inherited from
Contract.typedv2
Defined in
node_modules/starknet/dist/index.d.ts:3997