Skip to content

NEARFeeContract

SIP Protocol API Reference v0.7.4


SIP Protocol API Reference / NEARFeeContract

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24576

NEAR Fee Contract Client

Provides interface for fee calculation and collection on NEAR.

const feeContract = new NEARFeeContract({
network: 'mainnet',
})
// Calculate fee
const fee = await feeContract.calculateFee({
amount: 1000000000000000000000000n, // 1 NEAR
amountUsd: 5.00,
sourceChain: 'near',
destinationChain: 'ethereum',
})
console.log(`Fee: ${fee.protocolFeeUsd} USD`)

new NEARFeeContract(options?): NEARFeeContract

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24583

NEARFeeContractOptions

NEARFeeContract

calculateFee(params): Promise<FeeCalculationResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24587

Calculate fee for a transaction

FeeCollectionParams

Promise<FeeCalculationResult>


estimateFee(amountUsd, sourceChain?): Promise<{ feeUsd: number; bps: number; tierName?: string; }>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24591

Get fee estimate for UI display

number

ChainId

Promise<{ feeUsd: number; bps: number; tierName?: string; }>


collectFee(params): Promise<FeeCollectionResult>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24602

Collect fee for a transaction

In production, this would create a NEAR transaction to transfer the fee to the treasury. For now, it simulates the collection.

FeeCollectionParams

Promise<FeeCollectionResult>


batchCollectFees(params): Promise<FeeCollectionResult[]>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24606

Batch collect fees for multiple transactions

FeeCollectionParams[]

Promise<FeeCollectionResult[]>


getState(): Promise<FeeContractState>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24610

Get contract state

Promise<FeeContractState>


getConfig(): Promise<ChainFeeConfig>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24614

Get fee configuration

Promise<ChainFeeConfig>


updateConfig(config): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24618

Update fee configuration (owner only)

Partial<ChainFeeConfig>

Promise<void>


getTreasury(): Promise<FeeTreasuryConfig>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24622

Get treasury configuration

Promise<FeeTreasuryConfig>


getStats(startTime?, endTime?): Promise<FeeStats>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24626

Get fee statistics

number

number

Promise<FeeStats>


pause(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24630

Pause fee collection (emergency)

Promise<void>


resume(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24634

Resume fee collection

Promise<void>


isPaused(): Promise<boolean>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24638

Check if fee collection is paused

Promise<boolean>


withdrawToTreasury(amount?): Promise<string>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24644

Withdraw fees to treasury

In production, this would create a NEAR transaction.

bigint

Promise<string>


getContractId(): string

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24648

Get contract ID

string


getNetwork(): "testnet" | "mainnet"

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24652

Get network

"testnet" | "mainnet"


getRpcUrl(): string

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:24656

Get RPC URL

string