create static method

ContractTemplate create({
  1. required Address owner,
  2. required Address receiver1,
  3. required Address receiver2,
  4. required int rat1,
  5. required int rat2,
  6. required int expiryRound,
  7. required int minPay,
  8. required int maxFee,
})

Create a new Split Contract. Split allows locking algos in an account which allows transfering to two predefined addresses in a specified ratio such that for the given ratn and ratd parameters we have:

first_recipient_amount * rat_2 == second_recipient_amount * rat_1

Split also has an expiry round, after which the owner can transfer back the funds.

Implementation

static ContractTemplate create({
  required Address owner,
  required Address receiver1,
  required Address receiver2,
  required int rat1,
  required int rat2,
  required int expiryRound,
  required int minPay,
  required int maxFee,
}) {
  final values = List.of([
    IntParameterValue(4, maxFee),
    IntParameterValue(7, expiryRound),
    IntParameterValue(8, rat2),
    IntParameterValue(9, rat1),
    IntParameterValue(10, minPay),
    AddressParameterValue(14, owner),
    AddressParameterValue(47, receiver1),
    AddressParameterValue(80, receiver2),
  ], growable: false);

  return ContractTemplate.inject(
    program: base64Decode(referenceProgram),
    values: values,
  );
}