Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimism and BASE testnets; USD premiums #1831

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions src/content/chainlink-functions/resources/billing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: "Chainlink Functions Billing"
---

import { Aside } from "@components"
import { TabsContent } from "@components/Tabs"

## Request costs

Expand Down Expand Up @@ -41,6 +42,8 @@ During the **request** step:
total estimated cost in LINK = total estimated gas cost + premium fees
```

For networks with USD-denominated premium fees, the fixed premium fee is denominated in USD but no USD is ever used. The LINK equivalent of this fee is calculated at request time.

1. The total estimated cost is then added to the subscription reservation.

### Cost calculation (fulfillment)
Expand All @@ -55,14 +58,23 @@ When a DON's oracle reports the response, subscription accounts are charged base
total cost in LINK = total gas cost + premium fees
```

For networks with USD-denominated premium fees, the LINK equivalent of the fixed premium fee was calculated at request time. At response time, this calculated value in LINK is charged to your subscription.

1. The FunctionsRouter contract performs several accounting movements.

### Cost calculation example

This is an example of cost estimation for a request and then cost calculation at fulfillment.

For networks with USD-denominated premium fees, the premium fees are set in USD, but no USD is ever used. The LINK equivalent of the fee is calculated at request time, and then deducted from your subscription in LINK at response time.

#### Cost Simulation (Reservation)

{/* prettier-ignore */}
<TabsContent sharedStore="feeType" client:visible>
<Fragment slot="tab.1">LINK-denominated premium fee</Fragment>
<Fragment slot="tab.2">USD-denominated premium fee</Fragment>
<Fragment slot="panel.1">
| Parameter | Value |
| ----------------------- | -------- |
| Overestimated gas price | 9 gwei |
Expand Down Expand Up @@ -93,8 +105,55 @@ This is an example of cost estimation for a request and then cost calculation at

For this example request, 0.82 LINK is reserved from your subscription balance, but not yet deducted. When the request is fulfilled, the exact request cost is deducted. The estimated cost of a request is overestimated to allow for 99% of gas price fluctuation increases in between request and response time.

</Fragment>
<Fragment slot="panel.2">
| Parameter | Value |
| ----------------------- | -------- |
| Overestimated gas price | 9 gwei |
| Callback gas limit | 300000 |
| Gas overhead | 185000 |
| Premium fee | 320 cents USD |

1. Calculate the total estimated gas cost in LINK, using an overestimated gas price, the gas overhead, and the full callback gas limit:

| Gas cost calculation | Total estimated gas cost |
| ------------------------------------------------------------- | --------------------------- |
| Overestimated gas price x (Gas overhead + Callback gas limit) | |
| 9 gwei x (300000 + 185000) | 4365000 gwei (0.004365 ETH) |

1. Convert the gas cost to LINK using the [LINK/ETH feed](https://data.chain.link/ethereum/mainnet/crypto-eth/link-eth).
For this example, assume the feed returns a conversion value of Ξ0.007 ETH per 1 LINK.

| ETH to LINK cost conversion | Total gas cost (LINK) |
| ----------------------------- | --------------------- |
| 0.004365 ETH / 0.007 ETH/LINK | 0.62 LINK |

1. Convert the USD-denominated premium fee to LINK using the [LINK/USD feed](https://data.chain.link/feeds/ethereum/mainnet/link-usd).
For this example, assume the feed returns a conversion value of $20.00 USD per 1 LINK:

| USD to LINK cost conversion | Premium fee (LINK) |
| --------------------------- | ------------------ |
| $3.20 USD / 20.00 USD/LINK | 0.16 LINK |

1. Add the converted premium fee to get the estimated cost for a subscription reservation:

| Adding converted LINK premium | Maximum request cost (LINK) |
| ----------------------------------- | --------------------------- |
| Total gas cost (LINK) + Premium fee | |
| 0.62 LINK + 0.16 LINK | 0.78 LINK |

For this example request, 0.78 LINK is reserved from your subscription balance, but not yet deducted. When the request is fulfilled, the exact request cost is deducted. The estimated cost of a request is overestimated to allow for 99% of gas price fluctuation increases in between request and response time.

</Fragment>
</TabsContent>

#### Cost calculation (fulfillment)

{/* prettier-ignore */}
<TabsContent sharedStore="feeType" client:visible>
<Fragment slot="tab.1">LINK-denominated premium fee</Fragment>
<Fragment slot="tab.2">USD-denominated premium fee</Fragment>
<Fragment slot="panel.1">
| Parameter | Value |
| ------------ | -------- |
| Gas price | 1.5 gwei |
Expand Down Expand Up @@ -125,6 +184,41 @@ For this example request, 0.82 LINK is reserved from your subscription balance,

This example request would cost 0.2825 LINK when it is fulfilled. The subscription reservation for the 0.82 LINK is released, and the actual cost of 0.2825 LINK is deducted from your subscription balance.

</Fragment>
<Fragment slot="panel.2">
| Parameter | Value |
| ------------ | -------- |
| Gas price | 1.5 gwei |
| Callback gas | 200000 |
| Gas overhead | 185000 |
| Premium fee converted to LINK | 0.16 LINK |

1. Calculate the total gas cost:

| Gas cost calculation | Total gas cost |
| ----------------------------------------- | --------------------------- |
| Gas price x (Gas overhead + Callback gas) | |
| 1.5 gwei x (200000 + 185000) | 577500 gwei (0.0005775 ETH) |

1. Convert the gas cost to LINK using the [LINK/ETH feed](https://data.chain.link/ethereum/mainnet/crypto-eth/link-eth).
For this example, assume the feed returns a conversion value of Ξ0.007 ETH per 1 LINK.

| ETH to LINK cost conversion | Total gas cost (LINK) |
| ------------------------------ | --------------------- |
| 0.0005775 ETH / 0.007 ETH/LINK | 0.0825 LINK |

1. The premium fee was converted from USD to LINK at the time of the request. Add this converted premium fee to get the total cost of a request:

| Adding premium fee | Total request cost (LINK) |
| ----------------------------------- | ------------------------- |
| Total gas cost (LINK) + premium fee | |
| 0.0825 LINK + 0.16 LINK | 0.2425 LINK |

This example request would cost 0.2425 LINK when it is fulfilled. The subscription reservation for the 0.78 LINK is released, and the actual cost of 0.2425 LINK is deducted from your subscription balance.

</Fragment>
</TabsContent>

## Minimum balance for uploading encrypted secrets

If you choose to store the encrypted secrets with the DON (learn more on the [Secrets Management page](/chainlink-functions/resources/secrets)), then one of your subscriptions must maintain a balance greater than the minimum required for uploading encrypted secrets. This balance is blockchain-specific. You can find the specific values for each blockchain on the [Supported Networks](/chainlink-functions/supported-networks) page.
Expand Down
9 changes: 9 additions & 0 deletions src/content/chainlink-functions/resources/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ title: "Chainlink Functions Release Notes"

import { Aside } from "@components"

## USD-denominated premium fees and new testnets - 2024-03-22

Chainlink Functions is available as an open beta on the following testnets:

- [BASE Sepolia](/chainlink-functions/supported-networks#base-sepolia-testnet)
- [Optimism Sepolia](/chainlink-functions/supported-networks#optimism-sepolia-testnet)

Both of these networks have USD-denominated fixed premium fees. This means that the premium fees are set in USD, but no USD is ever used. The LINK equivalent of the fee is calculated at request time, and then deducted from your subscription in LINK at response time. See the [example cost calculation](/chainlink-functions/resources/billing#cost-calculation-example) for more information.

## Module imports supported on mainnet - 2024-01-12

- You can use external module imports with Chainlink Functions source code on mainnet networks. See the [Using Imports with Functions](/chainlink-functions/tutorials/importing-packages) tutorial to see an example of how to import and use imported modules with your Functions source code. This feature requires the [Functions Toolkit NPM package](https://www.npmjs.com/package/@chainlink/functions-toolkit/v/0.2.7) `v0.2.7` or later.
Expand Down
48 changes: 47 additions & 1 deletion src/content/chainlink-functions/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: "Supported Networks"
---

import ResourcesCallout from "@features/resources/callouts/ResourcesCallout.astro"
import { Address, CopyText } from "@components"
import { Aside, Address, CopyText } from "@components"
import { DonId } from "@features/chainlink-functions"

Read the [LINK Token Contracts](/resources/link-token-contracts) page to learn where to get testnet LINK and ETH.
Expand Down Expand Up @@ -139,3 +139,49 @@ Read the [LINK Token Contracts](/resources/link-token-contracts) page to learn w
| Request threshold (withdrawing funds) | 10 requests |
| Cancellation fees (withdrawing funds) | 2 LINK |
| Minimum balance for uploading encrypted secrets | 2 LINK |

## BASE

<Aside type="note" title="USD-denominated premium fees">
The fixed premium fee is denominated in USD but no USD is ever used. The LINK equivalent of the fee is calculated at
request time, and then deducted from your subscription in LINK at response time. See the [example cost
calculation](/chainlink-functions/resources/billing#cost-calculation-example) for more information.
</Aside>

### BASE Sepolia testnet

| Item | Value |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Functions router | <Address contractUrl="https://sepolia.basescan.org/address/0xf9B8fc078197181C841c296C876945aaa425B278" /> |
| <DonId client:load/> | <CopyText text="fun-base-sepolia-1" code /> / <CopyText text="0x66756e2d626173652d7365706f6c69612d310000000000000000000000000000"code format formatType="bytes32" /> |
| Encrypted secrets upload endpoints | <ul><li><CopyText text="https://01.functions-gateway.testnet.chain.link/" code /></li><li><CopyText text="https://02.functions-gateway.testnet.chain.link/" code /></li></ul> |

| Billing Item | Value |
| ------------------------------------------------ | ------------- |
| Premium fees (converted to LINK at request time) | 320 cents USD |
| Request threshold (withdrawing funds) | 10 requests |
| Cancellation fees (withdrawing funds) | 2 LINK |
| Minimum balance for uploading encrypted secrets | 2 LINK |

## Optimism

<Aside type="note" title="USD-denominated premium fees">
The fixed premium fee is denominated in USD but no USD is ever used. The LINK equivalent of the fee is calculated at
request time, and then deducted from your subscription in LINK at response time. See the [example cost
calculation](/chainlink-functions/resources/billing#cost-calculation-example) for more information.
</Aside>

### Optimism Sepolia testnet

| Item | Value |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Functions router | <Address contractUrl="https://sepolia-optimism.etherscan.io/address/0xC17094E3A1348E5C7544D4fF8A36c28f2C6AAE28" /> |
| <DonId client:load/> | <CopyText text="fun-optimism-sepolia-1" code /> / <CopyText text="0x66756e2d6f7074696d69736d2d7365706f6c69612d3100000000000000000000"code format formatType="bytes32" /> |
| Encrypted secrets upload endpoints | <ul><li><CopyText text="https://01.functions-gateway.testnet.chain.link/" code /></li><li><CopyText text="https://02.functions-gateway.testnet.chain.link/" code /></li></ul> |

| Billing Item | Value |
| ------------------------------------------------ | ------------- |
| Premium fees (converted to LINK at request time) | 320 cents USD |
| Request threshold (withdrawing funds) | 10 requests |
| Cancellation fees (withdrawing funds) | 2 LINK |
| Minimum balance for uploading encrypted secrets | 2 LINK |
2 changes: 2 additions & 0 deletions src/features/landing/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export const evmProducts = [
{ id: "polygon", title: "Polygon" },
{ id: "avalanche", title: "Avalanche" },
{ id: "arbitrum", title: "Arbitrum" },
{ id: "optimism", title: "Optimism" },
{ id: "base", title: "BASE" },
],
},
{
Expand Down
Loading