Smart Contracts

Dualis Finance settles all lending, collateral, liquidation, and governance operations on the Canton Network using DAML smart contracts. The contract suite comprises 25 modules exposing 38 templates, built with DAML SDK 3.4.11 targeting Ledger Fragment (LF) version 2.1.

Architecture

The DAML contracts are organized into functional categories. Each module defines one or more templates with explicit signatory and observer relationships, enforcing Canton's privacy model at the ledger level. Contract keys have been removed as LF 2.x does not support the key/maintainer syntax — all contract references use contract IDs.

No Contract Keys
DAML LF 2.1 removes support for contract keys. All lookups in the Dualis contracts use contract IDs passed explicitly in choice arguments. This is a deliberate design decision aligned with Canton's privacy-first architecture.

Module Categories

CategoryModulesDescription
CoreDualis.Types, Dualis.UtilsShared type definitions (CreditTier, InterestRateModel, TierLendingParams) and math utilities (Taylor series exp/ln)
LendingDualis.LendingPool, Dualis.Supply, Dualis.Borrow, Dualis.RepayPool creation, supply/withdraw, borrow/repay lifecycle, interest accrual
LiquidationDualis.Liquidation, Dualis.LiquidationAuctionHealth factor monitoring, liquidation triggers, Dutch auction mechanism
CreditDualis.Credit, Dualis.CreditOracleCredit tier assignment (Diamond/Gold/Silver/Bronze/Unrated), rate discounts, LTV caps
OracleDualis.Oracle, Dualis.PriceFeedPrice feed submissions, staleness checks, multi-source aggregation
Token / GovernanceDualis.Token, Dualis.Governance, Dualis.Staking, Dualis.VotingProtocol token, governance proposals, staking rewards, vote delegation
Securities LendingDualis.SecLending, Dualis.SecLendingMatchOffer creation, matching engine, settlement, recall mechanism
InstitutionalDualis.Institutional, Dualis.SubAccount, Dualis.ComplianceInstitutional onboarding, sub-account management, KYC/AML integration
ProductiveDualis.Productive, Dualis.Vault, Dualis.StrategyYield vaults, auto-compounding strategies, fee distribution
PrivacyDualis.Privacy, Dualis.PrivacyPolicyTransaction privacy controls, observer management, disclosure policies
TriggersDualis.Triggers, Dualis.AutoLiquidation, Dualis.InterestAccrualAutomated DAML triggers for liquidation execution and interest index updates

Template List

The 38 templates across all modules:

#TemplateModuleKey Choices
1LendingPoolLendingPoolSupply, Withdraw, UpdateRates
2SupplyPositionSupplyAccrueInterest, Redeem
3BorrowPositionBorrowAccrueInterest, Repay, AddCollateral
4BorrowRequestBorrowApprove, Reject
5RepaymentReceiptRepayArchive
6CollateralLockBorrowRelease, Liquidate
7LiquidationTriggerLiquidationExecute, Cancel
8LiquidationAuctionLiquidationAuctionBid, Settle, Expire
9CreditAssignmentCreditUpgrade, Downgrade, Revoke
10CreditOracleEntryCreditOracleUpdateScore, Expire
11PriceFeedPriceFeedSubmitPrice, Invalidate
12OracleConfigOracleAddSource, RemoveSource, UpdateStaleness
13ProtocolTokenTokenTransfer, Mint, Burn
14TokenAllowanceTokenSpend, Revoke
15GovernanceProposalGovernanceVote, Execute, Cancel
16ProposalResultGovernanceFinalize
17StakePositionStakingUnstake, ClaimRewards
18StakeRewardStakingDistribute, Compound
19VoteDelegationVotingDelegate, Revoke
20VoteRecordVotingArchive
21SecLendingOfferSecLendingMatch, Cancel, Expire
22SecLendingContractSecLendingMatchReturn, Recall, Default
23InstitutionalAccountInstitutionalCreateSubAccount, UpdateLimits
24SubAccountSubAccountExecute, Freeze, Close
25ComplianceRecordComplianceVerify, Reject, Expire
26KycStatusComplianceApprove, Revoke
27YieldVaultVaultDeposit, Withdraw, Rebalance
28VaultShareVaultRedeem, Transfer
29StrategyStrategyExecute, Pause, UpdateParams
30StrategyResultStrategyDistribute, Reinvest
31ProductivePositionProductiveHarvest, Compound, Exit
32FeeDistributionProductiveClaim, Reinvest
33PrivacyPolicyPrivacyPolicyAddObserver, RemoveObserver
34PrivacyConfigPrivacyUpdateDefaults, GrantException
35FlashLoanLendingPoolExecute, Repay
36InterestIndexInterestAccrualAccrue, Snapshot
37LiquidationBotAutoLiquidationScan, Execute, Report
38TriggerConfigTriggersEnable, Disable, UpdateFrequency

Building

The DAML source lives in packages/canton/daml/. Build and test with the DAML SDK (version 3.4.11):

Terminal
cd packages/canton/daml
~/.daml/bin/daml build

The build produces a DAR (DAML Archive) file:

Output
.daml/dist/dualis-finance-2.0.0.dar

Testing

The contract suite includes 8 test files covering all template lifecycle scenarios. Run the full test suite:

Terminal
cd packages/canton/daml
~/.daml/bin/daml test
DAML Math
DAML has no native exp or ln functions. The Dualis.Utils module implements these using Taylor series approximations, validated against the TypeScript math engine in the shared package to ensure cross-platform consistency.

Deployment

Upload the compiled DAR to a Canton participant using the deployment script:

Terminal
./deploy/scripts/upload-dar.sh \
  --dar .daml/dist/dualis-finance-2.0.0.dar \
  --participant-url http://172.18.0.7:5001

On the current devnet, the DAR has been uploaded with 134 packages registered on the participant node (13 from dualis-finance, the rest are DAML standard library dependencies).

LF Version
The contracts target LF 2.1. Attempting to upload to a participant running an older Canton version that only supports LF 1.x will fail. Ensure your Canton validator is v0.5.12 or newer.