Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

loans state

Back to all declarations

Denom

untyped string

Denom is the only asset this realm accepts.

Value

"ugnot"

MaxFeeBps

int64

MaxFeeBps is the hard protocol-fee cap: 1000 bps = 10%.

Value

1000

LoanActive

untyped string

Loan status values. Repaid and Defaulted are terminal.

Value

"active"

LoanRepaid

untyped string

Loan status values. Repaid and Defaulted are terminal.

Value

"repaid"

LoanDefaulted

untyped string

Loan status values. Repaid and Defaulted are terminal.

Value

"defaulted"

MinPrincipal

int64

Input bounds.

Value

1000

MaxPrincipal

int64

// 1,000,000 GNOT

Value

1000000000000

MaxRateBps

int64

Input bounds.

Value

10000

MinInstallments

int64

Input bounds.

Value

1

MaxInstallments

int64

Input bounds.

Value

60

MinPeriodBlocks

int64

Input bounds.

Value

10

MaxPeriodBlocks

int64

Input bounds.

Value

7500000

MaxLoansPerLender

untyped bigint

Input bounds.

Value

(50 <untyped> bigint)

RenderLimit

untyped bigint

Input bounds.

Value

(20 <untyped> bigint)

loan

type

Value

loans.loan

admin

.uverse.address

Value

<gnolang.StringValue>

pendingAdmin

.uverse.address

Value

<zero>

feeRecipient

.uverse.address

Value

<gnolang.StringValue>

feeBps

int64

// snapshotted into NEW loans

Value

0

self

.uverse.address

Value

<gnolang.StringValue>

nextID

int64

Value

2

lenderNum

*v0.Tree

// lender.String() -> \*int64, stored loans

Open
OID
081106…55c4:13
lenderNum details

Inspect pointer

Open

func(borrower .uverse.address, rateBps int64, installments int64, periodBlocks int64) int64

Open funds a loan: the caller (the lender) attaches the principal, which is disbursed to borrower in this same transaction, and the loan is recorded with a flat finance charge of rateBps of the principal, repayable over \`installments\` installments of \`periodBlocks\` blocks each. The current protocol fee is snapshotted in. Returns the loan id.

Open
OID
081106…55c4:22
Open details

Inspect func

Claim

func(amount int64)

Claim sends amount ugnot of the caller's claimable balance (repayments collected on their loans, net of the protocol fee) back to the caller.

Open
OID
081106…55c4:23
Claim details

Inspect func

ClaimAll

func()

ClaimAll sends the caller's entire claimable balance back to the caller.

Open
OID
081106…55c4:24
ClaimAll details

Inspect func

Repay

func(loanID int64)

Repay pays toward the caller's own loan. The caller must be the loan's borrower; the attached amount must be positive and must not exceed the outstanding balance. The payment credits the lender's claimable balance (the protocol fee splitting off at the ledger); when the cumulative repaid equals the total, the loan is Repaid. Repaying ahead of schedule is allowed.

Open
OID
081106…55c4:25
Repay details

Inspect func

Default

func(loanID int64)

Default marks an active loan defaulted once it is past its grace window — the final installment's due height plus one more period — and not repaid in full. Permissionless by design: no loan's terminal state may depend on either party acting. No coins move; the shortfall is recorded.

Open
OID
081106…55c4:26
Default details

Inspect func

SetFeeRecipient

func(recipient .uverse.address)
Open
OID
081106…55c4:28
SetFeeRecipient details

Inspect func

SweepDenom

func(denom string)

SweepDenom recovers out-of-band coins to the fee recipient. For the ledger denom the reserve is Liabilities() — lender balances and the fee pot are structurally unreachable.

Open
OID
081106…55c4:30
SweepDenom details

Inspect func

TransferAdmin

func(successor .uverse.address)
Open
OID
081106…55c4:31
TransferAdmin details

Inspect func

LoanInfo

func(loanID int64) (lender .uverse.address, borrower .uverse.address, principal int64, total int64, repaid int64, installments int64, periodBlocks int64, startHeight int64, status string)
Open
OID
081106…55c4:33
LoanInfo details

Inspect func

InstallmentAmount

func(loanID int64) int64

InstallmentAmount is the per-installment amount: ceil(total/installments), with the rounding remainder carried on the FINAL installment so the installments sum to exactly the total.

Open
OID
081106…55c4:34
InstallmentAmount details

Inspect func

Outstanding

func(loanID int64) int64

Outstanding is total − repaid.

Open
OID
081106…55c4:35
Outstanding details

Inspect func

ScheduledDue

func(loanID int64) int64

ScheduledDue is the cumulative amount that should have been repaid by the current height: the sum of every installment whose due height has passed, capped at the total. Installment k (1-based) is due at start + k·period.

Open
OID
081106…55c4:36
ScheduledDue details

Inspect func

AmountDueNow

func(loanID int64) int64

AmountDueNow is how far behind schedule the borrower is right now: ScheduledDue − repaid, floored at zero (a borrower who has prepaid is not behind).

Open
OID
081106…55c4:37
AmountDueNow details

Inspect func

DefaultableAt

func(loanID int64) int64

DefaultableAt is the height at or after which an unpaid loan may be Defaulted: the final installment's due height plus one grace period.

Open
OID
081106…55c4:38
DefaultableAt details

Inspect func

IsDefaultable

func(loanID int64) bool

IsDefaultable reports whether the loan may be Defaulted right now.

Open
OID
081106…55c4:39
IsDefaultable details

Inspect func

LoansOf

func(lender .uverse.address) int64
Open
OID
081106…55c4:41
LoansOf details

Inspect func

PendingAdmin

func() .uverse.address
Open
OID
081106…55c4:43
PendingAdmin details

Inspect func

FeeRecipient

func() .uverse.address
Open
OID
081106…55c4:44
FeeRecipient details

Inspect func

ClaimableOf

func(a .uverse.address) int64
Open
OID
081106…55c4:47
ClaimableOf details

Inspect func

scheduledDue

func(l *loans.loan, now int64) int64

scheduledDue is the cumulative amount owed by \`now\`: k installments' worth where k is how many installment due-heights have passed, capped at total.

Open
OID
081106…55c4:53
scheduledDue details

Inspect func

defaultableAt

func(l *loans.loan) int64

defaultableAt is the final installment's due height plus one grace period.

Open
OID
081106…55c4:54
defaultableAt details

Inspect func

mustLoan

func(id int64) *loans.loan
Open
OID
081106…55c4:55
mustLoan details

Inspect func

counter

func(tree *v0.Tree, a .uverse.address) *int64
Open
OID
081106…55c4:57
counter details

Inspect func

ceilDiv

func(a int64, b int64) int64

ceilDiv returns ceil(a/b) for positive b; a,b assumed non-negative and b>0 (installments >= MinInstallments >= 1).

Open
OID
081106…55c4:58
ceilDiv details

Inspect func

addChecked

func(a int64, b int64) (int64, bool)
Open
OID
081106…55c4:59
addChecked details

Inspect func

mulChecked

func(a int64, b int64) (int64, bool)
Open
OID
081106…55c4:60
mulChecked details

Inspect func

mulDivChecked

func(a int64, b int64, d int64) (int64, bool)

mulDivChecked returns floor(a\*b/d) without overflowing on the intermediate product, by dividing before multiplying where it can and checking the product otherwise. Here d is 10000 and a,b are bounded, so the simple checked product suffices; the helper names the intent and guards it.

Open
OID
081106…55c4:61
mulDivChecked details

Inspect func

renderLoan

func(idStr string) string
Open
OID
081106…55c4:66
renderLoan details

Inspect func

hasPrefix

func(s string, p string) bool
Open
OID
081106…55c4:67
hasPrefix details

Inspect func
Denom : untyped string ="ugnot"
MaxFeeBps : int64 =1000
LoanActive : untyped string ="active"
LoanRepaid : untyped string ="repaid"
LoanDefaulted : untyped string ="defaulted"
MinPrincipal : int64 =1000
MaxPrincipal : int64 =1000000000000
MaxRateBps : int64 =10000
MinInstallments : int64 =1
MaxInstallments : int64 =60
MinPeriodBlocks : int64 =10
MaxPeriodBlocks : int64 =7500000
MaxLoansPerLender : untyped bigint =(50 <untyped> bigint)
RenderLimit : untyped bigint =(20 <untyped> bigint)
loan : type =loans.loan
admin : .uverse.address =<gnolang.StringValue>
pendingAdmin : .uverse.address =<zero>
feeRecipient : .uverse.address =<gnolang.StringValue>
feeBps : int64 =0
self : .uverse.address =<gnolang.StringValue>
nextID : int64 =2
loans : *v0.Tree Inspect
lenderNum : *v0.Tree Inspect
ledger : *feeledger.Ledger Inspect
init.24 : func() Inspect
Open : func(borrower .uverse.address, rateBps int64, installments int64, periodBlocks int64) int64 Inspect
Claim : func(amount int64) Inspect
ClaimAll : func() Inspect
Repay : func(loanID int64) Inspect
Default : func(loanID int64) Inspect
SetFeeBps : func(bps int64) Inspect
SetFeeRecipient : func(recipient .uverse.address) Inspect
WithdrawFees : func() Inspect
SweepDenom : func(denom string) Inspect
TransferAdmin : func(successor .uverse.address) Inspect
AcceptAdmin : func() Inspect
LoanInfo : func(loanID int64) (lender .uverse.address, borrower .uverse.address, principal int64, total int64, repaid int64, installments int64, periodBlocks int64, startHeight int64, status string) Inspect
InstallmentAmount : func(loanID int64) int64 Inspect
Outstanding : func(loanID int64) int64 Inspect
ScheduledDue : func(loanID int64) int64 Inspect
AmountDueNow : func(loanID int64) int64 Inspect
DefaultableAt : func(loanID int64) int64 Inspect
IsDefaultable : func(loanID int64) bool Inspect
HasLoan : func(loanID int64) bool Inspect
LoansOf : func(lender .uverse.address) int64 Inspect
Admin : func() .uverse.address Inspect
PendingAdmin : func() .uverse.address Inspect
FeeRecipient : func() .uverse.address Inspect
FeeBps : func() int64 Inspect
NumLoans : func() int64 Inspect
ClaimableOf : func(a .uverse.address) int64 Inspect
FeesAccrued : func() int64 Inspect
Liabilities : func() int64 Inspect
Held : func() int64 Inspect
Address : func() .uverse.address Inspect
Height : func() int64 Inspect
scheduledDue : func(l *loans.loan, now int64) int64 Inspect
defaultableAt : func(l *loans.loan) int64 Inspect
mustLoan : func(id int64) *loans.loan Inspect
assertNoSend : func() Inspect
counter : func(tree *v0.Tree, a .uverse.address) *int64 Inspect
ceilDiv : func(a int64, b int64) int64 Inspect
addChecked : func(a int64, b int64) (int64, bool) Inspect
mulChecked : func(a int64, b int64) (int64, bool) Inspect
mulDivChecked : func(a int64, b int64, d int64) (int64, bool) Inspect
padID : func(id int64) string Inspect
itoa : func(n int64) string Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
renderLoan : func(idStr string) string Inspect
hasPrefix : func(s string, p string) bool Inspect