Skip to content

NEARFeeContract

SIP Protocol API Reference v0.12.0


SIP Protocol API Reference / NEARFeeContract

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24876

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-rqQpCeVM.d.ts:24883

NEARFeeContractOptions

NEARFeeContract

calculateFee(params): Promise<FeeCalculationResult>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24887

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-rqQpCeVM.d.ts:24891

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-rqQpCeVM.d.ts:24902

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-rqQpCeVM.d.ts:24906

Batch collect fees for multiple transactions

FeeCollectionParams[]

Promise<FeeCollectionResult[]>


getState(): Promise<FeeContractState>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24910

Get contract state

Promise<FeeContractState>


getConfig(): Promise<ChainFeeConfig>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24914

Get fee configuration

Promise<ChainFeeConfig>


updateConfig(config): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24918

Update fee configuration (owner only)

Partial<ChainFeeConfig>

Promise<void>


getTreasury(): Promise<FeeTreasuryConfig>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24922

Get treasury configuration

Promise<FeeTreasuryConfig>


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

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24926

Get fee statistics

number

number

Promise<FeeStats>


pause(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24930

Pause fee collection (emergency)

Promise<void>


resume(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24934

Resume fee collection

Promise<void>


isPaused(): Promise<boolean>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24938

Check if fee collection is paused

Promise<boolean>


withdrawToTreasury(amount?): Promise<string>

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24944

Withdraw fees to treasury

In production, this would create a NEAR transaction.

bigint

Promise<string>


getContractId(): string

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24948

Get contract ID

string


getNetwork(): "testnet" | "mainnet"

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24952

Get network

"testnet" | "mainnet"


getRpcUrl(): string

Defined in: @sip-protocol/sdk/dist/index-rqQpCeVM.d.ts:24956

Get RPC URL

string