> For the complete documentation index, see [llms.txt](https://docs.xft.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xft.finance/bitnet/technical/swap-facilities/xftinterestrateswap.md).

# XFTInterestRateSwap

**COUNTERPARTIES**

XFTInterestRateSwap [0x3F2Dbe13CFA87150F4ae93406f8032767bdc59D9](https://sepolia.arbiscan.io/address/0x3f2dbe13cfa87150f4ae93406f8032767bdc59d9)

**FUNCTIONS**

* initiateSwap(): Create swap with atomic deposits
* updateFloatingRate(): Admin updates rate before maturity
* settleSwap(): Admin settles with preimage verification
* refundSwap(): Parties recover funds after expiry
* calculatePayments(): Preview settlement amounts
* getSwapDetails(): View swap parameters

Swap\
1 user → IRS: notional USDXT\
2 user2 → IRS: notional USDXT\
3 admin updates floatingRate in IRS\
4 time passes to maturity\
5 admin calls settleSwap with preimage\
6 IRS calculates fixedPayment and floatingPayment\
7 IRS sends net interest USDXT to owed party\
8 IRS returns notionals to user and user2

SEQUENCE

```
INITIATE SWAP
1 user calls initiateSwap(swapId,counterparty,notional,fixedRate,floatingRate,maturity,hashlock,dayCount)
2 contract pulls notional from fixedPayer and floatingPayer atomically
3 emits NotionalDeposited and SwapInitiated

RATE MANAGEMENT
4 admin calls updateFloatingRate(swapId,newRate) before maturity
5 emits FloatingRateUpdated

SETTLEMENT
6 after block.timestamp ≥ maturity, admin calls settleSwap(swapId,preimage)
7 contract verifies hashlock, calculates fixed vs floating using dayCount
8 returns notionals and net interest atomically
9 emits SwapSettled
10 deletes swap storage for gas reclaim

REFUND
11 if not settled and block.timestamp ≥ maturity, either party calls refundSwap(swapId)
12 returns both notionals atomically
13 emits SwapRefunded and deletes storage

```

**CONTRACT ABI**

```
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"swapId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"newRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"FloatingRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"swapId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"fixedPayer","type":"address"},{"indexed":true,"internalType":"address","name":"floatingPayer","type":"address"},{"indexed":false,"internalType":"uint256","name":"notionalAmount","type":"uint256"}],"name":"NotionalDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"swapId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"fixedPayer","type":"address"},{"indexed":true,"internalType":"address","name":"floatingPayer","type":"address"},{"indexed":false,"internalType":"uint256","name":"notionalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"floatingRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maturity","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"hashlock","type":"bytes32"},{"indexed":false,"internalType":"enum XFTInterestRateSwap.DayCountConvention","name":"dayCount","type":"uint8"}],"name":"SwapInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"swapId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"refunder","type":"address"}],"name":"SwapRefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"swapId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"fixedPayment","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"floatingPayment","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netPayment","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"bytes32","name":"preimage","type":"bytes32"}],"name":"SwapSettled","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDXT","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"}],"name":"calculatePayments","outputs":[{"internalType":"uint256","name":"fixedPayment","type":"uint256"},{"internalType":"uint256","name":"floatingPayment","type":"uint256"},{"internalType":"uint256","name":"netPayment","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"}],"name":"getSwapDetails","outputs":[{"internalType":"address","name":"fixedPayer","type":"address"},{"internalType":"address","name":"floatingPayer","type":"address"},{"internalType":"uint256","name":"notionalAmount","type":"uint256"},{"internalType":"uint256","name":"fixedRate","type":"uint256"},{"internalType":"uint256","name":"floatingRate","type":"uint256"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"bytes32","name":"hashlock","type":"bytes32"},{"internalType":"enum XFTInterestRateSwap.DayCountConvention","name":"dayCount","type":"uint8"},{"internalType":"bool","name":"settled","type":"bool"},{"internalType":"bool","name":"refunded","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUSDXTAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"},{"internalType":"address","name":"_floatingPayer","type":"address"},{"internalType":"uint256","name":"_notionalAmount","type":"uint256"},{"internalType":"uint256","name":"_fixedRate","type":"uint256"},{"internalType":"uint256","name":"_floatingRate","type":"uint256"},{"internalType":"uint256","name":"_maturity","type":"uint256"},{"internalType":"bytes32","name":"_hashlock","type":"bytes32"},{"internalType":"enum XFTInterestRateSwap.DayCountConvention","name":"_dayCount","type":"uint8"}],"name":"initiateSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"}],"name":"refundSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"},{"internalType":"bytes32","name":"_preimage","type":"bytes32"}],"name":"settleSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"}],"name":"swapExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"swaps","outputs":[{"internalType":"address","name":"fixedPayer","type":"address"},{"internalType":"address","name":"floatingPayer","type":"address"},{"internalType":"uint256","name":"notionalAmount","type":"uint256"},{"internalType":"uint256","name":"fixedRate","type":"uint256"},{"internalType":"uint256","name":"floatingRate","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"bytes32","name":"hashlock","type":"bytes32"},{"internalType":"enum XFTInterestRateSwap.DayCountConvention","name":"dayCount","type":"uint8"},{"internalType":"bool","name":"notionalDeposited","type":"bool"},{"internalType":"bool","name":"settled","type":"bool"},{"internalType":"bool","name":"refunded","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_swapId","type":"bytes32"},{"internalType":"uint256","name":"_newRate","type":"uint256"}],"name":"updateFloatingRate","outputs":[],"stateMutability":"nonpayable","type":"function"}]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xft.finance/bitnet/technical/swap-facilities/xftinterestrateswap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
