Skip to content

NEARFeeContract

SIP Protocol API Reference v0.15.1


SIP Protocol API Reference / NEARFeeContract

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24912

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-GLbkPPho.d.ts:24919

NEARFeeContractOptions

NEARFeeContract

calculateFee(params): Promise<FeeCalculationResult>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24923

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-GLbkPPho.d.ts:24927

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-GLbkPPho.d.ts:24938

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-GLbkPPho.d.ts:24942

Batch collect fees for multiple transactions

FeeCollectionParams[]

Promise<FeeCollectionResult[]>


getState(): Promise<FeeContractState>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24946

Get contract state

Promise<FeeContractState>


getConfig(): Promise<ChainFeeConfig>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24950

Get fee configuration

Promise<ChainFeeConfig>


updateConfig(config): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24954

Update fee configuration (owner only)

Partial<ChainFeeConfig>

Promise<void>


getTreasury(): Promise<FeeTreasuryConfig>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24958

Get treasury configuration

Promise<FeeTreasuryConfig>


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

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24962

Get fee statistics

number

number

Promise<FeeStats>


pause(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24966

Pause fee collection (emergency)

Promise<void>


resume(): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24970

Resume fee collection

Promise<void>


isPaused(): Promise<boolean>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24974

Check if fee collection is paused

Promise<boolean>


withdrawToTreasury(amount?): Promise<string>

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24980

Withdraw fees to treasury

In production, this would create a NEAR transaction.

bigint

Promise<string>


getContractId(): string

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24984

Get contract ID

string


getNetwork(): "testnet" | "mainnet"

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24988

Get network

"testnet" | "mainnet"


getRpcUrl(): string

Defined in: @sip-protocol/sdk/dist/index-GLbkPPho.d.ts:24992

Get RPC URL

string