Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions sui/packages/atoma/sources/db.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ module atoma::db {
use sui::table::{Self, Table};
use sui::vec_set::{Self, VecSet};
use toma::toma::TOMA;
use usdc::usdc::USDC;

// THIS NEEDS TO BE OUR ADDRESS WHERE THE MONEY
const OUR_ADDRESS: address = @0xd5f66ef59f66b4d90e2620077b23ad7cd7425e8425a626630f4a1c742933e4e1;
/// How many epochs after the stack expires during which any disputes must be resolved.
const STACK_DISPUTE_SETTLEMENT_DELAY: u64 = 2;

Expand Down Expand Up @@ -1383,7 +1386,7 @@ module atoma::db {
/// Emits a StackCreatedEvent containing details about the newly created stack.
entry fun acquire_new_stack_entry(
self: &mut AtomaDb,
wallet: &mut Coin<TOMA>,
wallet: &mut Coin<USDC>,
task_small_id: u64,
num_compute_units: u64,
price: u64,
Expand Down Expand Up @@ -1432,7 +1435,7 @@ module atoma::db {
/// - A new SmallId is assigned to the stack, incrementing the `next_stack_small_id` counter.
fun acquire_new_stack(
self: &mut AtomaDb,
wallet: &mut Balance<TOMA>,
wallet: &mut Balance<USDC>,
task_small_id: u64,
num_compute_units: u64,
price: u64,
Expand Down Expand Up @@ -1460,7 +1463,9 @@ module atoma::db {
assert!(balance::value(wallet) >= fee_amount, EInsufficientBalance);
// Transfer the funds to the contract
let funds = wallet.split(fee_amount);
self.deposit_to_fee_treasury(funds);
let wallet = coin::from_balance(funds, ctx);
transfer::public_transfer(wallet, OUR_ADDRESS);
// self.deposit_to_fee_treasury(funds);
};

// Sample a node and create the stack
Expand Down
49 changes: 49 additions & 0 deletions sui/packages/stablecoin/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 2
manifest_digest = "2D16DF7BBB460E26A4151FFCA9834972024289FF6DFDD87F005D543C741A929E"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
dependencies = [
{ name = "Sui" },
{ name = "sui_extensions" },
]

[[move.package]]
name = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "a4185da5659d8d299d34e1bb2515ff1f7e32a20a", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
name = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "a4185da5659d8d299d34e1bb2515ff1f7e32a20a", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ name = "MoveStdlib" },
]

[[move.package]]
name = "sui_extensions"
source = { local = "../sui_extensions" }

dependencies = [
{ name = "Sui" },
]

[move.toolchain-version]
compiler-version = "1.32.2"
edition = "2024.beta"
flavor = "sui"

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x346e3233f61eb0055713417bfaddda7dc3bf26816faad1f7606994a368b92917"
latest-published-id = "0x346e3233f61eb0055713417bfaddda7dc3bf26816faad1f7606994a368b92917"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0xecf47609d7da919ea98e7fd04f6e0648a0a79b337aaad373fa37aac8febf19c8"
latest-published-id = "0xecf47609d7da919ea98e7fd04f6e0648a0a79b337aaad373fa37aac8febf19c8"
published-version = "1"
35 changes: 35 additions & 0 deletions sui/packages/stablecoin/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Circle Internet Group, Inc. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[package]
name = "stablecoin"
edition = "2024.beta"
license = "Apache 2.0"

[dependencies.Sui]
git = "https://github.com/MystenLabs/sui.git"
subdir = "crates/sui-framework/packages/sui-framework"
rev = "framework/testnet"

[dependencies.sui_extensions]
local = "../sui_extensions"

[addresses]
stablecoin = "0x0"

[dev-dependencies]

[dev-addresses]
73 changes: 73 additions & 0 deletions sui/packages/stablecoin/sources/entry.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2024 Circle Internet Group, Inc. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// This module exposes entry functions for the stablecoin module to support calling functions on
/// wrapped objects from PTBs. Currently PTBs are unable to chain a reference from the output of one
/// function to the input of another, making it difficult to call functions on wrapped objects.
/// This module exposes those functions directly using entry functions.
module stablecoin::entry {
use stablecoin::treasury::Treasury;

// === Entry Functions ===

/// Start owner role transfer process.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun transfer_ownership<T>(treasury: &mut Treasury<T>, new_owner: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().owner_role_mut().begin_role_transfer(new_owner, ctx)
}

/// Finalize owner role transfer process.
/// - Only callable by the pending owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun accept_ownership<T>(treasury: &mut Treasury<T>, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().owner_role_mut().accept_role(ctx)
}

/// Change the master minter address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_master_minter<T>(treasury: &mut Treasury<T>, new_master_minter: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_master_minter(new_master_minter, ctx)
}

/// Change the blocklister address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_blocklister<T>(treasury: &mut Treasury<T>, new_blocklister: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_blocklister(new_blocklister, ctx)
}

/// Change the pauser address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_pauser<T>(treasury: &mut Treasury<T>, new_pauser: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_pauser(new_pauser, ctx)
}

/// Change the metadata updater address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_metadata_updater<T>(treasury: &mut Treasury<T>, new_metadata_updater: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_metadata_updater(new_metadata_updater, ctx)
}
}
59 changes: 59 additions & 0 deletions sui/packages/stablecoin/sources/mint_allowance.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024 Circle Internet Group, Inc. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

module stablecoin::mint_allowance {

const EOverflow: u64 = 0;
const EInsufficientAllowance: u64 = 1;

/// A MintAllowance for a coin of type T.
/// Used for minting and burning.
public struct MintAllowance<phantom T> has store {
value: u64
}

/// [Package private] Gets the current allowance of the MintAllowance object.
public(package) fun value<T>(self: &MintAllowance<T>): u64 {
self.value
}

/// [Package private] Create a new MintAllowance for type T.
public(package) fun new<T>(): MintAllowance<T> {
MintAllowance { value: 0 }
}

/// [Package private] Set allowance to `value`
public(package) fun set<T>(self: &mut MintAllowance<T>, value: u64) {
self.value = value;
}

/// [Package private] Increase the allowance by `value`
public(package) fun increase<T>(self: &mut MintAllowance<T>, value: u64) {
assert!(value < (18446744073709551615u64 - self.value), EOverflow);
self.value = self.value + value;
}

/// [Package private] Decrease the allowance by `value`
public(package) fun decrease<T>(self: &mut MintAllowance<T>, value: u64) {
assert!(self.value >= value, EInsufficientAllowance);
self.value = self.value - value;
}

/// [Package private] Destroy object
public(package) fun destroy<T>(self: MintAllowance<T>) {
let MintAllowance { value: _ } = self;
}
}
Loading