@0xknwn/starknet-test-helpers / Exports / SwapRouter

Class: SwapRouter

Represents a Swap contract.

Hierarchy

  • Contract

    SwapRouter

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new SwapRouter(address, account): SwapRouter

Creates an instance of the Counter contract.

Parameters

NameTypeDescription
addressstringThe address of the contract.
accountAccountThe account used to interact with the contract.

Returns

SwapRouter

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

NameType
addressstring

Returns

void

Inherited from

Contract.attach

Defined in

node_modules/starknet/dist/index.d.ts:3987


call

call(method, args?, «destructured»?): Promise<Result>

Parameters

NameType
methodstring
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

NameType
providerOrAccountProviderInterface | 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

NameType
methodstring
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

NameTypeDescription
amountUint256The 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

NameType
methodstring
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

NameType
receiptGetTransactionReceiptResponse

Returns

ParsedEvents

Inherited from

Contract.parseEvents

Defined in

node_modules/starknet/dist/index.d.ts:3994


populate

populate(method, args?): Call

Parameters

NameType
methodstring
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

NameTypeDescription
ratestringThe 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

NameTypeDescription
tokenAAddressstringThe address of tokenA.
tokenBAddressstringThe 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

NameTypeDescription
tokenAAddressstringThe address of the token to be swapped.
amountUint256The 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

NameTypeDescription
tokenAAddressstringThe address of the token A.
ratestringThe rate at which to swap the tokens.
amountUint256The 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

NameTypeDescription
tokenAAddressstringThe address of the token A.
ratestringThe rate of the swap.
amountUint256The 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

NameType
TAbiextends readonly (AbiImpl | AbiInterface | AbiConstructor | AbiFunction | AbiStruct | AbiEnum | AbiEvent)[]

Parameters

NameType
tAbiTAbi

Returns

TypedContractV2<TAbi>

Inherited from

Contract.typedv2

Defined in

node_modules/starknet/dist/index.d.ts:3997