Skip to content

@loktin/sdk / spend-save / SpendSave

Class: SpendSave ​

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:28

Spend & Save for the configured publicKey, with one integrator. Every write acts for publicKey, and every check that needs no chain data runs before any network call.

Constructors ​

Constructor ​

new SpendSave(loktin, options): SpendSave

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:37

Checks the options, with no network call.

Parameters ​

loktin ​

Loktin

options ​

IntegratorOptions

Returns ​

SpendSave

Properties ​

integrator ​

readonly integrator: string

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:30

The integrator's address.


integratorFeeBps ​

readonly integratorFeeBps: number

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:32

The integrator fee a new enrolment receives.

Methods ​

accruedFees() ​

accruedFees(recipient?): Promise<bigint>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:101

Returns the fees accrued to recipient and not yet claimed (W63). recipient defaults to the module's integrator.

Parameters ​

recipient? ​

string

Returns ​

Promise<bigint>


claimFees() ​

claimFees(): Promise<WriteResult<bigint>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:96

Pays out every fee accrued to publicKey and returns the amount (W63). The call acts for publicKey, so it needs only the configured signer. An integrator claims by creating the SDK with its own publicKey and signer, and Loktin's fee recipient claims the same way. With nothing accrued, the contract refuses it with NothingToClaim. Never uses the read adapter.

Returns ​

Promise<WriteResult<bigint>>


close() ​

close(): Promise<WriteResult<null>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:62

Closes the enrolment, whose balance must be zero (S9).

Returns ​

Promise<WriteResult<null>>


enroll() ​

enroll(input): Promise<WriteResult<null>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:40

Enrols publicKey with the integrator (P12, P13, P16, S9).

Parameters ​

input ​

EnrollInput

Returns ​

Promise<WriteResult<null>>


enrollment() ​

enrollment(): Promise<EnrollmentView>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:69

Returns the enrolment of publicKey with the integrator, and the withdrawal day that applies now. effectiveWithdrawalDay is for display: it uses the device clock in UTC, and at the edge of a month the chain decides.

Returns ​

Promise<EnrollmentView>


feeRecipient() ​

feeRecipient(): Promise<string>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:87

Returns the address Loktin fees are paid to.

Returns ​

Promise<string>


loktinFeeBps() ​

loktinFeeBps(): Promise<number>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:85

Returns the Loktin fee rate new enrolments receive.

Returns ​

Promise<number>


nextWindow() ​

nextWindow(): Promise<TimeWindow>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:79

Returns the current withdrawal window if one is open, otherwise the next one, with any pending day change applied. end is the first second after the window.

Returns ​

Promise<TimeWindow>


paused() ​

paused(): Promise<boolean>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:103

Returns whether Spend & Save is paused.

Returns ​

Promise<boolean>


payAndSave() ​

payAndSave(to, amount): Promise<WriteResult<Saving>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:50

Pays amount from publicKey to to, an account (G), muxed account (M) or contract (C) address, and saves the skim in the same call (P11, P14).

Parameters ​

to ​

string

amount ​

bigint

Returns ​

Promise<WriteResult<Saving>>


previewSkim() ​

previewSkim(spent): Promise<SkimPreview>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:71

Returns how a spend would be skimmed now, before the wallet is checked.

Parameters ​

spent ​

bigint

Returns ​

Promise<SkimPreview>


previewWithdraw() ​

previewWithdraw(amount): Promise<SpendSaveWithdrawal>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:73

Returns how a withdrawal of amount would split. Does not check the withdrawal window.

Parameters ​

amount ​

bigint

Returns ​

Promise<SpendSaveWithdrawal>


saveForSpend() ​

saveForSpend(spent): Promise<WriteResult<Saving>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:52

Saves the skim on a spend publicKey made by other means (P11).

Parameters ​

spent ​

bigint

Returns ​

Promise<WriteResult<Saving>>


targetSavings() ​

targetSavings(): Promise<string | undefined>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:81

Returns the Target Savings contract skims may go to, if any.

Returns ​

Promise<string | undefined>


token() ​

token(): Promise<string>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:83

Returns the token Spend & Save holds.

Returns ​

Promise<string>


updateSettings() ​

updateSettings(input): Promise<WriteResult<null>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:45

Replaces the skim settings, cap and destination at once. A new withdrawal day takes effect from next month (P16, S9). Fee rates never change.

Parameters ​

input ​

EnrollInput

Returns ​

Promise<WriteResult<null>>


withdraw() ​

withdraw(amount): Promise<WriteResult<SpendSaveWithdrawal>>

Defined in: @loktin/sdk/dist/spend-save/spend-save.d.ts:60

Withdraws amount from the balance. The chain refuses it outside the withdrawal window (P16, S9, R2). The user receives toUser. The integrator fee accrues to the integrator, and the Loktin fee to Loktin's fee recipient, who each claim them with SpendSave.claimFees.

Parameters ​

amount ​

bigint

Returns ​

Promise<WriteResult<SpendSaveWithdrawal>>

Built on Stellar