Smart Contracts

Deployments

Since Polymarket’s smart contracts are deployed on Polygon, ours are as well. The deployment addresses are:

Name
Network
Address

Source Code

The GitHub repository contains smart contracts and associated files needed for development, testing, and deployment

The main smart contract is located here:

Roles

  • Borrower

    • Owns a conditional token position.

    • Requests a loan and accepts an offer.

    • Can repay early at any time.

  • Lender

    • Provides USDC liquidity.

    • Makes loan offers.

    • Can call a loan after its minimum duration.

    • Can transfer a called loan to themselves (refinancing) or reclaim collateral if the auction fails.

Public Functions

Helper Functions

External contracts

  • IConditionalTokens (ERC-1155)

    • Represents Polymarket conditional token positions.

    • Collateral is identified by (positionId, collateralAmount).

  • ERC20 USDC

    • The stablecoin being lent/borrowed.

  • ISafeProxyFactory

    • Used to derive smart-account wallets (e.g., Gnosis Safe) for borrowers/lenders when _useProxy = true.

  • ERC1155TokenReceiver

    • Base contract so PolyLend can safely receive ERC-1155 collateral.

Storage

Events

For integration / indexing:

  • LoanRequested(uint256 id, address borrower, address borrowerWallet, uint256 positionId, uint256 collateralAmount, uint256 minimumDuration)

  • LoanOffered(uint256 id, uint256 requestId, address lender, uint256 loanAmount, uint256 rate)

  • LoanAccepted(uint256 id, uint256 requestId, uint256 offerId, uint256 startTime)

  • LoanCalled(uint256 id, uint256 callTime)

  • LoanTransferred(uint256 oldId, uint256 newId, address newLender, uint256 newRate)

  • LoanRepaid(uint256 id)

  • LoanReclaimed(uint256 id)

  • LoanRequestCanceled(uint256 id)

  • LoanOfferCanceled(uint256 id)

Errors

  • CollateralAmountIsZero

  • InsufficientCollateralBalance

  • CollateralIsNotApproved

  • OnlyBorrower

  • OnlyLender

  • InvalidRequest

  • InvalidOffer

  • InvalidLoan

  • InsufficientFunds

  • InsufficientAllowance

  • InvalidRate

  • InvalidRepayTimestamp

  • LoanIsNotCalled

  • LoanIsCalled

  • MinimumDurationHasNotPassed

  • AuctionHasEnded

  • AuctionHasNotEnded

These make it easy for front-ends and bots to surface precise error messages.

Last updated